Make sed ignore lines

Hi

I use sed in a script for severall changes in files. I whish one of the substitutions I made to be aplied to every line that has the word "scripts" with the exception for the ones that start with "rsh", wich I wish sed to ignore . Is this possible? If yes, how can I do it?

The substitution I made is this one:

s/\(.*scripts\)/$BUSINESS_SCRIPTS/

Thank you.

Carlos

For all lines which does not contain rshscripts

sed -e "!/.*rshscripts.*/p" -e "/\(.*scripts\)/$BUSINESS_SCRIPTS/g"

Not tested tho'.

Vino

apply some change:

s/\(.*scripts\)/$BUSINESS_SCRIPTS/

apply the change only to those lines NOT starting with "rsh":

/^rsh/ ! {
            s/\(.*scripts\)/$BUSINESS_SCRIPTS/
           }

The first Regexp limits the execution of the substitution to those lines matched by it. The exclamation mark reverses this limitation. You can place multiple commands between the curly braces, they all will get executed only for those lines matched (or not not matched, respectively) by the first Regexp. Think of it as the sed-equivalent of "if ... then ..."

bakunin

bakunin