您的位置:首页 > 运维架构 > Shell

linux/shell 文本文件删除/删掉空行

2017-04-30 11:02 1276 查看
分别用sed awk perl grep 实现:

1 sed '/^$/d' input.txt > output.txt    #output file: output.txt
2 sed -i '/^$/d' input.txt      #output file: input.txt
3 awk 'NF > 0' input.txt > output.txt     #output file: output.txt
4 perl -i.backup -n -e "print if /\S/" input.txt   #output file: input.txt.backup
5 grep -v '^$' input.txt > output.txt    #output file: output.txt
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: