Monday, January 3, 2011

perl: remove all blank lines of a file

Without saving a backup of the previous file:
perl -ni -e 'print unless /^$/' file

Saving the original file as file.bak:
perl -ni.bak -e 'print unless /^$/' file

No comments: