I have a file which contains some text and - on a single line - a marker which indicates where new content should be added
foo bar %SUBSTITUTE% foo
The line line substitute should be replaced by a new multiline string
text="some text" (note that I do not know the string it may for instance be the result of reading a file
text=cat "file"``). The result of the replacement should read
foo bar some text %SUBSTITUTE% foo
I had a working version based on
perl which stopped working (apparently due to perl version change). Now I am trying standard utilities like
sed to replace the line.
I am having some trouble with it, because the string to be pasted may contain arbitrary characters including backslashes etc. I do not want to escape these before pasting.
Is there a safe way to do it which works with standard tools? The other questions I find for the problem are particular solutions where the text to be pasted is known.