August 17, 2010

Remove blank/empty lines from a file

There are many ways to do it:

  • grep '.' file > newfile
  • awk '/./' file > newfile
But, please make sure your file is in "Unix" format, not "Dos" format (this concerns the line ending character). If it is in "Dos" format, none of the script works. You can convert it using vim and do "set fileformat=unix" then save, or use dos2unix command.

No comments:

Post a Comment