Thursday, June 18, 2009

Get rid of unwanted lines using unix

There are two ways:
First method.
1. Open the text file: vi filename.dat
2. :1,$ s/.*keywordsofthelines.*//g --> from first line(1) to the last line($), substract all lines contain the keyword
3. :wq -->write and save
4. sort filename | uniq > t --> sort it and pipe to uniq and save it into temporary t
5. mv t filename --> move all the data from tempoprary t to the file.

Second.
1. Open the text file in vi: vi filename.dat
2.Delete all the start and bottom rubbish stuff. go to the line and type dd
3. :wq
4. grep -F "recalled" filename > outfile

tips from Kerri Morgan

No comments:

Post a Comment