Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with sed/awk issue

Status
Not open for further replies.

g2345c

Technical User
Jun 23, 2004
22
US
I want to do the following but have no clue. Please suggest.

1) I want to search in a file "config.txt" for a line that started with "*" follow by anything, then "LOG" then "one or more tab" then /var/log (ex: *124adfadf;*LOG /var/log). If I found this line I want to remove "LOG" and save the file

sed -e '/^\*.*LOG/b' -e .... config.txt >config.txt.$$ && mv config.txt.$$ config.txt

2) I want to search in a file "config.txt" for a line that contains "/GOT/IT" and remove it.
sed ..... config.txt >config.txt.$$ && mv config.txt.$$ config.txt

Thanks a lot
 
Something like this ?
1)
t=`echo "\t\c"`
sed "/^\*.*LOG$t$t*\/var\/log/s!LOG!!" config.txt >config.txt.$$ && mv config.txt.$$ config.txt
2)
sed 's!/GOT/IT!!' config.txt >config.txt.$$ && mv config.txt.$$ config.txt

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top