试试这样:
sed '/^$/d' input | awk '{print $0"\n"}' >output
处理input文件。
首先用sed去掉所有空行,然后通过awk在逐行打印时再加上一个空行。
结果保存到output文件中。