从插入文件的多行文本到模式之后另一个文件 [英] Inserting multiline text from file to another file after pattern

查看:118
本文介绍了从插入文件的多行文本到模式之后另一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的文件:


  

text2insert结果
  filewithpattern


和也称:


  

模式


我怎样才能插入来自 text2insert 行到 filewithpattern 模式行?

使用bash 2.05b以上。

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


  

垃圾结果
  样式1结果
  PATTERN2结果
  垃圾


和后:


  

垃圾结果
  样式1结果
  text2insert线结果
  text2insert线结果
  text2insert线结果
  PATTERN2结果
  垃圾



解决方案

  SED -e'/模式/ R text2insert'filewithpattern

I have files like:

text2insert
filewithpattern

and also known:

pattern

How can i insert lines from text2insert into filewithpattern but after the pattern line?

Using bash 2.05b

UPDATE: Before filewithpattern should look like:

garbage
pattern1
pattern2
garbage

and after:

garbage
pattern1
text2insert lines
text2insert lines
text2insert lines
pattern2
garbage

解决方案

sed -e '/pattern/r text2insert' filewithpattern

这篇关于从插入文件的多行文本到模式之后另一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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