I am trying to copy a part of a file into another file at a specific location.
I can't use sed -i '/match/r fileToInsert' file because I want to insert only some content of fileToInsert, not the whole file.
My fileToInsert is as follow:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- OriginalName: test.xml -->
<ListModes>
...
I tried this:
sed -i "/match/a$(sed -n '2,3p' fileToInsert)" file
But it does not work either because fileToInsert is an xml file and sed chokes on the second line when encountering the opening "<":
sed -e expression #1, char 59: unknown command: `<'
(it works if I try with just one line though).
Is there any way to achieve what I want on linux ? Could be with sed, awk or any other existing utility on a redhat distribution.