I use shell scripts to setup different types of VMs. Often these scripts include multiline variables that need to be inserted into config files at certain positions using
If I create them like this, everything is fine:
VAR="Config Line1\nConfig Line2\nConfig Line 3" sed -i "/MatchingPattern/ a $VAR" somefile
This doesn't make the script very readable though, especially since the text blocks can be quite long.
If I write them like so:
VAR="Config Line1 Config Line2 Config Line 3" sed -i "/MatchingPattern/ a $VAR" somefile
I get an error when running the script:
sed: -e expression #1, char 31: unknown command:C'`
Is there a way to use
sed with variables declared like that?