I have a file like this:
data data data
$globaltext blah gibberjabber
somemorestuff etc
);
data data data
$otherjunk yada gibberish
etc etc
more etc
);
My desired result is this file:
data data data
/*$globaltext blah gibberjabber
somemorestuff etc
);*/
data data data
/*$otherjunk yada gibberish
etc etc
more etc
);*/
I know how to do it using a for loop with sed, but I'd like a 1-line sed command to achieve that, Something like:
sed '/blah\|yada/s/^\(\$.*)\;\)/\/\*\1\*\//' filename
The pattern match at the beginning limits the search to 1 line, so obviously the above command fails. But the concept is what I want:
- Match any of a list of patterns (
blahoryada), - then add desired text (
/*) to beginning of the matched line, - AND add other desired text (
*/) to the end of the next line matching a different pattern ();) where the # of lines between the 2 matches varies (its not always 2 lines apart etc)
Is that possible or should I use for loop or a better method?
Mostly asking to learn, since I'm new to shell scripting.
-eparameters -- one forblah|yadaand the other for);