Let's say file.txt contains empty lines.
line 1 line 3 line 5 line 7
The following sed command will remove the empty lines. The regular expression looks for the beginning (^) of a line immediately followed by the end ($) of a line, and if matched, deletes (d) the line.
~]# sed '/^$/d' file.txt line 1 line 3 line 5 line 7
Remember that the -i option must be used to actually perform this change on the file.
~]# sed -i '/^$/d' file.txt line 1 line 3 line 5 line 7