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

Data extraction to same file name

Status
Not open for further replies.

new2unix

Programmer
Feb 5, 2001
143
US
Hi Everyone,

I need advice on how to extract data from a file named, err_msg.log. This file contain different type of error msg with corresponding header. Basically, I need to skip any line in this file containing the following string, "ID ERROR" and output other lines that do not have this string. The other catch here is the output file name will be the same as the source file name, "err_msg.log". Is it possible?

Thanks

Mike
 
you can skip any lines with "ID ERROR" by using:

grep -v "ID ERROR" err_msg.log

this will go to stnd out, however you can not redirect to the exact same filename.

grep -v "ID ERROR" err_msg.log > err_msg.log (WILL NOT WORK)

you need to go to a tmp file, and then move the contents back to the origional file.

crowe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top