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

How to delete a line in a file with Unix command ?

Status
Not open for further replies.

Rosti

Programmer
Mar 5, 2002
46
0
0
US
What is the best way to delete blank lines in the flat file using Unix commands ?
Please help.
 
rosti,

Assuming the blank lines are completely empty, this should work

[tt] grep -v &quot;^$&quot; < original.txt > noblanks.txt[/tt]

grep -v displays all strings that do not match the search string. ^ and $ match the beginning and end of a line respectively, hence ^$ matches an empty line.

Annihilannic.
 
Thanks a lot for the help.
It works !
Rosti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top