通过grep删除文本文件中的空行 [英] Remove empty lines in a text file via grep
本文介绍了通过grep删除文本文件中的空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hello
世界
foo
bar
可以删除 FILE
中所有空的新行吗?
命令输出:
FILE
:
hello
world
foo
bar
解决方案
grep。 FILE
(如果你真的想在sed中完成,那么: sed -e / ^ $ / d FILE
)
(如果你真的想用awk做,那么: awk /./FILE
)
FILE
:
hello
world
foo
bar
How can when remove all the empty new lines in this FILE
?
Output of command:
FILE
:
hello
world
foo
bar
解决方案
grep . FILE
(And if you really want to do it in sed, then: sed -e /^$/d FILE
)
(And if you really want to do it in awk, then: awk /./ FILE
)
这篇关于通过grep删除文本文件中的空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文