How to remove blank lines from a Unix file
sed -i ‘/^$/d’ foo This tells sed to delete every line matching the regex ^$ i.e. every empty line. The -i flag edits the file in-place, if your sed doesn’t support that you can write the output to a temporary file and replace the original: sed ‘/^$/d’ foo > foo.tmp mv foo.tmp foo If you … Read more