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!

Removing lines from log file

Status
Not open for further replies.

zenosan

Programmer
Jan 16, 2008
3
US
I would like to remove all the lines except for the |1751|141| line and |1753|142| line.

|7|126|53874
|7|127|0
|129|128|8 77876 0 0 0 1393542 1280 0 0
|129|130|8 77876 0 0 0 1393542 1280 0 0
|129|132|8 41703 0 0 0 756323 735 0 0

|1751|141|1 |1|85|1|41|47|0|0|0|0|0|0|54|319|667|509|177|54|17|3|1|0|1|0|0|0
|1753|142|1 |1|0|0|20|16|3|7|1048|512|144|80|16|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0

|128|143|9 11 0 0 0 0 0 0 0 0
|128|144|9 198 0 0 0 0 0 0 0 0
|128|145|9 4 0 0 0 0 0 0 0 0
|1819|152|1 |1|0|0|0|0
|1946|157|1 |1|0|0|0
|128|158|9 0 0 0 0 0 0 0 0 0
|128|159|6 0 0 0 0 0 0

I tried using sed, however, it deleted all lines.
 
I tried using sed, however, it deleted all lines
Which code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
What about a simple grep?

grep -e '^|1751|141' -e '^|1753|142'


 
[tt]

$ awk '$0 ~/1751|141/ || /1753|142/ {print}' data
|1751|141|1 |1|85|1|41|47|0|0|0|0|0|0|54|319|667|509|177|54|17|3|1|0|1|0|0|0
|1753|142|1 |1|0|0|20|16|3|7|1048|512|144|80|16|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0




[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top