I have a similar scenario. I have an xml file which I compiled in unix and i send it out as an attachment which opens with excel. Now there are certain keywords (kw01)in the xml file which I wanted to replace with the contents of txt files having multiple lines.
So i tried your code above with this command:
sed '/kw01/r fatal_alerts.txt' template.xml | sed '/kw01/d' > test.xml
now when I sent out the output file 'test.xml' and open it via excel, the cell where 'kw01' is located is not replaced with the contents of 'fatal_alerts.txt'.
Is there a possible way to do this sir? Need your help badly.
#!/bin/bash
# tested with bash 4
file2=$(<file2)
while read -r line
do
case "$line" in
*NOVEMBER*)
line="$file2"
;;
esac
echo "$line"
done < file1 > t && mv t file1