in reply to New Line at End File


Here is a one-liner:     perl -i.bak -ne '/^$/ ? $i++ : do{print "\n" x $i, $_; $i=0}' file

See also Re: Re: Remove Blank Lines Off the End of a File and comments.

--
John.