The changes are made in-place so change -i to -i.bak if you want to keep a backup. perl -i -ne '/^$/ ? $i++ : do{print "\n" x $i, $_; $i=0}' file Update: I just ran PrakashK's program on the same test data. It took 0.1 sec!!
--
John.
In reply to Re: Remove Blank Lines Off the End of a File
by jmcnamara
in thread Remove Blank Lines Off the End of a File
by jbisbee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |