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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find and Replace

Status
Not open for further replies.
Jun 21, 2006
6
US
Hi
I have a logfile as follows
******************
timeout=100
users=120
home=/usr/kevin
capacity=222
capacity=666
*******************

I want to grep for the pattern "capacity=" and remove the characters following it.
****************************
timeout=100
users=120
home=/usr/kevin
*****************************

Please help me in writing a script which uses sed command for doing it ]#
Regards
Upilli
 
Hi

Code:
sed '/^capacity=/d' /input/file > /output/file

[gray]# or[/gray]

sed -n '/^capacity=/!p' /input/file > /output/file

[gray]# or[/gray]

grep -v "^capacity=" /input/file > /output/file

[gray]# or[/gray]

awk '!/^capacity=/' /input/file > /output/file

[gray]# or[/gray]

awk '/^capacity=/{next}1' /input/file > /output/file
GNU [tt]sed[/tt] supports in-place editing too :
Code:
sed -i '/^capacity=/d' /input/file

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top