I have several files that all contain a string. This string needs to be replaced by the whole content of another file (that can possibly be multi-line). How can I do this?What I need is something like sed -i 's/string/filename/' * where filename is an actual file and not the string filename.Additional info: The file can contain special characters such as / or \ or | or [ or ].
How to substitute a string in file with another file?
sed;replace
bash works well for this:$ cat replacefoo/bar\bazthe second line$ cat filethe replacement string goes >>here<<$ repl=$(<replace)$ str=here$ while IFS= read -r line; do    echo ${line//$str/$repl}done < filethe replacement string goes >>foo/bar\bazthe second line<<Awk would work, except that it will interpret backslash escapes (the \b in my example)$ awk -v string=here -v replacement=$(<replace) '    {gsub(string, replacement); print}' filethe replacement string goes >>foo/baazthe second line<<