Penguin
Note: You are viewing an old revision of this page. View the current version.

Removing empty lines from a file

perl -ni.bak -e 'print if /\S/' file1 file2

-i
means perl will edit the file in place and save a backup with the .bak extension
-e
means execute the code/command in the quotes
-n
read the manpage perlrun(1) for this one

The command will loop through the files you specify and print out the lines (into the file you specified) if they match the RegularExpression /\S/

AddToMe