我可以使用 sed 命令用一个空行替换多个空行吗? [英] Can I use the sed command to replace multiple empty line with one empty line?

查看:50
本文介绍了我可以使用 sed 命令用一个空行替换多个空行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 SO 如何用 bash 中的单个空行替换多个空行?.但我的问题是这可以通过使用 sed 命令来实现吗?

I know there is a similar question in SO How can I replace mutliple empty lines with a single empty line in bash?. But my question is can this be implemented by just using the sed command?

谢谢

推荐答案

试试这个:

sed '/^$/N;/^\n$/D' inputfile

这篇关于我可以使用 sed 命令用一个空行替换多个空行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆