![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| awk, ignore first x number of lines. | trey85stang | Shell Programming and Scripting | 8 | 05-21-2008 05:44 AM |
| How can I ignore only the lines which have # at the begining? | csaha | Shell Programming and Scripting | 1 | 01-30-2006 03:35 AM |
| Ignore Lines Begining With # | sysera | Shell Programming and Scripting | 4 | 08-23-2005 10:04 AM |
| Removing duplicate lines ignore case | hellsd | UNIX for Dummies Questions & Answers | 17 | 12-02-2004 10:47 AM |
| how to make a current running process ignore SIGHUP signal? | stevensxiao | UNIX for Advanced & Expert Users | 3 | 12-02-2003 01:35 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|