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

kas*_*per 5 bash

我有这样的文件:

text2insert
filewithpattern

并且还知道:

图案

我怎样才能插入来自行text2insertfilewithpattern,但之后的pattern线?

使用bash 2.05b

更新:之前filewithpattern应该看起来像:

垃圾
pattern1
pattern2
垃圾

之后:

垃圾
pattern1
text2insert lines
text2insert lines
text2insert lines
pattern2
garbage

Pau*_*ce. 5

sed -e '/pattern/r text2insert' filewithpattern
Run Code Online (Sandbox Code Playgroud)