I'm trying to use code that I found here: Insert contents of a file after specific pattern match
However, when I add a backslash to the code, it doesn't work. So, then, I followed the instructions here: Slash and backslash in sed to change the delimiters in sed
. However, when I do that, the insert (which should be a few lines), turns into thousands.
Here's my attempt:
sed ':<\tag>: r file1.txt' file2.txt
Example:
File1.txt
Hello World 1
Hello World 2
File2.txt:
<thanks>
<tag>
<example>
<new>
<\new>
<\example>
<\tag>
<\thanks>
Desired output:
<thanks>
<tag>
<example>
<new>
<\new>
<\example>
<\tag>
Hello World 1
Hello World 2
<\thanks>
If you could please help me insert the file contents after a line match while escaping a backslash, I would really appreciate it.