The UNIX and Linux Forums
>
Top Forums
>
Shell Programming and Scripting
Make sed ignore lines
.
User Name
Remember Me?
Password
google unix.com
Forums
Register
Forum Rules
Links
Albums
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
Thread
:
Make sed ignore lines
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
#
3
(
permalink
)
07-21-2005
bakunin
Bughunter Extraordinaire
Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,631
apply some change:
Code:
s/\(.*scripts\)/$BUSINESS_SCRIPTS/
apply the change only to those lines NOT starting with "rsh":
Code:
/^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
bakunin
View Public Profile
Find all posts by bakunin
Find bakunin's past nominations received
Find bakunin's present nominations given