加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – 如何在使用sed的一行之后插入换行符/换行符

发布时间:2020-12-15 19:21:15 所属栏目:安全 来源:网络整理
导读:花了我一段时间来弄清楚如何做到这一点,所以发布,以防其他人都在寻找相同的。 为了在模式之后添加换行符,您还可以说: sed '/pattern/{G;}' filename 报价GNU sed manual: G Append a newline to the contents of the pattern space,and then append the
花了我一段时间来弄清楚如何做到这一点,所以发布,以防其他人都在寻找相同的。
为了在模式之后添加换行符,您还可以说:
sed '/pattern/{G;}' filename

报价GNU sed manual:

G
    Append a newline to the contents of the pattern space,and then append the contents of the hold space to that of the pattern space.

编辑:

顺便说一下,这恰好在sed one liners:

# insert a blank line below every line which matches "regex"
 sed '/regex/G'

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读