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

时间:2014-08-02 12:17:53   收藏:0   阅读:256

分别用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

 

linux/shell 文本文件删除/删掉空行,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!