SpyTM Discussion Board

How to delete empty lines and lines only with white spaces from a file  

  RSS

admin
(@jayavinoth)
Member Admin
Joined:4 years  ago
Posts: 110
05/02/2016 11:49 pm  

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

ReplyQuote
Vijaya Ban
(@vijaya-ban)
New Member
Joined:2 years  ago
Posts: 1
18/02/2016 2:47 am  

Try:

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

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


ReplyQuote
  
Working

Please Login or Register