The UNIX and Linux Forums  

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



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-21-2005
Scarlos Scarlos is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 9
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
  #2 (permalink)  
Old 07-21-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
For all lines which does not contain rshscripts

Code:
sed -e "!/.*rshscripts.*/p" -e "/\(.*scripts\)/$BUSINESS_SCRIPTS/g"
Not tested tho'.

Vino
  #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,629
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0