This question already has an answer here:
- sed - replace string with file contents 4 answers
I'm attempting to replace a pattern in a file with the complete contents of another file using sed.
Currently I am using:
sed "s/PATTERN/`cat replacement.txt`/g" "openfile.txt" > "output.txt"
However, if the replacement file contains any characters such as
/ I start getting errors due to input not being sanitized.
I have been trying to use this guide to aid me, but I am finding it quite hard to follow. If I try the suggested
r file command, I just end up with a string.
What is the best way to approach this?