If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > sed with regular expression

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-04-03, 15:41
yan yan is offline
Registered User
 
Join Date: Feb 2003
Posts: 35
sed with regular expression

By using sed, how to express:
a pattern is found, but don't do anything to this line
e.g.: myfile has the following line and the pattern is "if"
aaaa
bbbb
if
cccc

I want to get:

echo aaaa
echo bbbb
if
echo cccc

Thanks for helping!
Reply With Quote
  #2 (permalink)  
Old 03-11-03, 12:20
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,543
Re: sed with regular expression

cat myfile | sed '/if/!s/^/echo /g'

HTH

Sathyaram
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On