从插入文件的多行文本到模式之后另一个文件 [英] Inserting multiline text from file to another file after pattern
本文介绍了从插入文件的多行文本到模式之后另一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的文件:
text2insert结果
filewithpattern
块引用>和也称:
模式
块引用>我怎样才能插入来自
text2insert
行到filewithpattern
但模式后code>行?
使用bash 2.05b以上。
更新:
之前filewithpattern
应该是这样的:
垃圾结果
样式1结果
PATTERN2结果
垃圾
块引用>和后:
垃圾结果
样式1结果
text2insert线结果
text2insert线结果
text2insert线结果
PATTERN2结果
垃圾
块引用>解决方案SED -e'/模式/ R text2insert'filewithpattern
I have files like:
text2insert
filewithpatternand also known:
pattern
How can i insert lines from
text2insert
intofilewithpattern
but after thepattern
line?Using bash 2.05b
UPDATE: Before
filewithpattern
should look like:garbage
pattern1
pattern2
garbageand after:
garbage
pattern1
text2insert lines
text2insert lines
text2insert lines
pattern2
garbage
解决方案sed -e '/pattern/r text2insert' filewithpattern
这篇关于从插入文件的多行文本到模式之后另一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文