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

bash – 在模式之后将多行文本从文件插入到另一个文件中

发布时间:2020-12-15 21:40:26 所属栏目:安全 来源:网络整理
导读:我有这样的文件: text2insert filewithpattern 并且还知道: pattern 我如何将text2insert中的行插入filewithpattern但在模式行之后? 使用bash 2.05b 更新: 在filewithpattern之前应该是这样的: garbage pattern1 pattern2 garbage 之后: garbage patte
我有这样的文件:

text2insert
filewithpattern

并且还知道:

pattern

我如何将text2insert中的行插入filewithpattern但在模式行之后?

使用bash 2.05b

更新:
在filewithpattern之前应该是这样的:

garbage
pattern1
pattern2
garbage

之后:

garbage
pattern1
text2insert lines
text2insert lines
text2insert lines
pattern2
garbage

解决方法

sed -e '/pattern/r text2insert' filewithpattern

(编辑:李大同)

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

    推荐文章
      热点阅读