Delete empty lines ...
 

Delete empty lines and lines only with white spaces from a file  


Alan
Posts: 35
 Alan
(@alan)
Eminent Member
Joined: 3 months ago

Below command helps me to remove only blank or empty lines from a file. Bit it not removes a line with white space.

sed '/^$/d' filename > filename.temp
1 Reply
admin
Posts: 93
Admin
(@mjv119gmail-com)
Member
Joined: 5 years ago

Try:

sed '/^ *$/d' filename > filename.tmp
filename.tmp > filename

This will remove blank lines and lines with only white spaces from a file.

Reply

Leave a reply


 
Preview 0 Revisions Saved
Share: