Home UNIX Remove blank lines from a file using grep

Remove blank lines from a file using grep

How can I remove blank lines from a file in UNIX?


grep -v "^$" filename > newfilename

The ^$ within the quotes is a regular expression: ^=beginning of line, $=end of line, with no characters between.

See additional helpful information in the comments below.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

error: Content is protected !!