The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 07-21-2005
bakunin bakunin is offline Forum Staff  
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