The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
make multiple line containing a pattern into single line VTAWKVT Shell Programming and Scripting 13 12-04-2008 06:40 PM
help with finding & replacing pattern in a file dusoo Shell Programming and Scripting 0 05-23-2008 03:59 AM
sed - Replace Line which contains the Pattern match with a new line kousikan Shell Programming and Scripting 2 03-24-2007 07:24 AM
Replacing a paragraph between pattern , with the content 4m another file go4desperado Shell Programming and Scripting 4 12-07-2006 09:44 AM
Replacing pattern in variable videsh77 Shell Programming and Scripting 1 05-26-2005 02:11 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 12-27-2006
Manan Manan is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 11
Replacing more than 1 pattern in a line

Hi, pls advise how we could make change to more than one pattern in a single line using sed..

ie:

IGNORE abcd delete}}}
COND IGNORE efgh}}}

will yield in

abcd delete}}
COND IGNORE efgh}}}

Pls note that IGNORE may not be in the start of line, IGNORE is intended to be removed only if it's the first word in the line together with closed bracked at the end of the line.

Thanks.
  #2 (permalink)  
Old 12-27-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Code:
sed '/^IGNORE.*}$/s/IGNORE//g' myFile
  #3 (permalink)  
Old 12-28-2006
Manan Manan is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 11
Hi, thanks..but there can be blanks before the first IGNORE and "}" at the end of the line need to be replaced as well....rgds.
  #4 (permalink)  
Old 12-28-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Quote:
Originally Posted by Manan
Hi, thanks..but there can be blanks before the first IGNORE and "}" at the end of the line need to be replaced as well....rgds.
Code:
sed '/^ *IGNORE.*} *$/s/IGNORE//g' myFile
  #5 (permalink)  
Old 12-28-2006
Manan Manan is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 11
Hi, thanks..I've got around the first blank earlier
But, i've got to replace }}} from that line to }}...so how shall a sed line does 2 pattern replace in a command...(ie IGNORE removal and } removal..)..thx.
  #6 (permalink)  
Old 12-28-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Quote:
Originally Posted by Manan
Hi, thanks..I've got around the first blank earlier
But, i've got to replace }}} from that line to }}...so how shall a sed line does 2 pattern replace in a command...(ie IGNORE removal and } removal..)..thx.
Code:
sed 's/^ *\(IGNORE\)\(.*\)\(} *\)/\2/g' myFile
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 10:44 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