本文翻译自:Delete empty lines using sed
I am trying to delete empty lines using sed: 我试图使用sed删除空行:
sed '/^$/d'
but I have no luck with it. 但我没有运气。
For example, I have these lines: 例如,我有这些行:
xxxxxx
yyyyyy
zzzzzz
and I want it to be like: 我希望它像:
xxxxxx
yyyyyy
zzzzzz
What should be the code for this? 应该是什么代码?
#1楼
参考:https://stackoom.com/question/16s8Y/使用sed删除空行
#2楼
sed '/^$/d'
should be fine, are you expecting to modify the file in place? sed &