【发布时间】:2017-10-12 17:17:11
【问题描述】:
我正在尝试使用在这里找到的代码:Insert contents of a file after specific pattern match
但是,当我在代码中添加反斜杠时,它不起作用。所以,然后,我按照这里的说明:Slash and backslash in sed 更改sed 中的分隔符。但是,当我这样做时,插入(应该是几行)变成了数千。
这是我的尝试:
sed ':<\tag>: r file1.txt' file2.txt
例子:
文件1.txt
Hello World 1
Hello World 2
文件2.txt:
<thanks>
<tag>
<example>
<new>
<\new>
<\example>
<\tag>
<\thanks>
期望的输出:
<thanks>
<tag>
<example>
<new>
<\new>
<\example>
<\tag>
Hello World 1
Hello World 2
<\thanks>
如果您能帮我在一行匹配后插入文件内容,同时转义反斜杠,我将不胜感激。
【问题讨论】: