Perl code to remove blank lines from a text file Posted on February 21, 2010 by rbocchinfuso Reply Remove blank lines from a text file with a single line of perl: perl -ni.bak -e ’s/^\s*$//’ filename