Deleting empty lines from text files (sed)

The following sed command deletes empty lines (and those with white spaces only) from text files: sed -e '/^ *$/d' infile.txt > outfile.txt You have to be careful though: if you copied the textfile from a Macintosh this script won't work. You first have to convert the Macintosh textfile into a UNIX textfile!