How to replace a pattern in one file with the contents of another file using sed?
Suppose I have fileA
, with the content
Hello, this is some
random text REPLACEHERE and some more
random text
and fileB
with content
stuff that goes into
fileA, at that specific place
How to properly replace REPLACEHERE
inside fileA
, with content fileB
? Exactly at this point, as if I were doing a simple regex operation?
The closest I got
sed -i '/REPLACEHERE/r fileB' fileA
which ends up adding fileB to the line after it REPLACEHERE
was found and that's not good. I need it to be replaced exactly in place (I thought there was actually a flag i
).
+3
source to share
1 answer