Basically I think this question is more one of regex than SED directly, but it’s SED I’m using, so that’s where I’m starting from.
I’ve got a web.config configuration file for an ASP.NET 2.0 website that I’m automating the build process for. I’m using UNIXUtils to give me some extra power over and above that provided by Windows. Using SED can someone enlighten me as to how I'd accomplish the following;
Data Source=RANDOM-SERVER;Initial Catalog=SomeDatabase;Persist Security Info=True;User ID=MyUser;Password=*************;
Data Source=PRODUCTION-SERVER;Initial Catalog=SomeDatabase;Persist Security Info=True;User ID=MyUser;Password=*************;
I’ve tried the following
sed s"|Data Source=.*;|Data Source=PRODUCTION-SERVER;|g"
but what I receive is
i.e. sed is helpfully being ultra greedy and eating all the characters up until the last semicolon, at least that’s what it seems to be doing.
BTW: Yes I would like to retain the |g greedy operator on the end to ensure that the alteration is applied to all occurrences in the original file, though, in theory there shouldn’t be.
If someone can show me how to accomplish this I'd be grateful, though I suspect there isn’t an easy way to do it, as I’ve not been able to find anything on the net that matches my requirements. Annoyingly everybody's focused on paths of one form or another.
If it can’t be done in SED but can be done using something else in the standard UNIXUtils suite, then that’s an acceptable answer, I’m open to suggestions.