Apologies if this is really obvious or it's been answered before (I can't find it in the wiki or the forums).
I need a way to replace a piece of text in a file1 with the contents of file2. In the file1, I already have a piece of 'placeholder' text, which is where the the contents of file2 are to be inserted.
I've seen various things like this:
perl -pi -e 's/find/replace/g'
sed -e 's/find/replace/' file
But what I can't figure out is how to get 'replace' to be the contents of a file, rather than a given string.
Specifically, what I'm trying to do is insert the base64 of file2 into an XML document (file1) which was generated using XSLT. But I coudn't find a way to do a base64 of a file in XSLT so I've used XSLT to insert a bit of placeholder text, and I hope to find a way of shell scripting the operation of inserting the base64 of file2 into the placeholder's position.
In the question, I'm assuming that file2 already contains the base64 of the file I want by using the shell command for that, but if the solution could do the base64 operation inline on the original file that'd be super-cool. Not having to rely on another command would be very handy.
I'll be running any solution on Red Hat Enterprise Linux 3 and/or 5.
Thanks in advance for any ideas.