I have a problem. I would like replace a line of a file by the content of another file.
In my first file I have this line: "#Content" and I would like to replace that with the content of the file content.xml.
Thanks.
This can work:
your_new_text=$(cat content.xml | sed 's/[^-A-Za-z0-9_]/\\&/g')
sed -i "s/#Content/$your_new_text/" your_file
It puts the text from content.xml in the variable $your_new_text. Then sed does the work: -i stands for replacing in the file, looks for #Content and replaces by text inside $your_new_text.
Note that it has to be wrapped with " to work.
This can work too, not very effective - but not sensitive to content.
cat <(sed '/#Content/,$d' < FILE ) content.xml <(sed '1,/#Content/d' < FILE) > NEWFILE
so, catenate