Delete blank lines at the end of file

I am attempting to delete blank lines in my file and I've used this command:
sed '/^$/d' $file > $file.fixed

all this seems to do is copy the file and not delete the blank lines located at the end of the file. Any assistance would be greatly appreciated.

one way:

{ rm FILE; sed -e '...' > FILE; } < FILE

unfortunately that still did not do the trick.

I found this command and it worked for me:
sed '/^ *$/d'

Thank you very much for responding and your assistance.

1 Like