I would have though this would have been simple, but...
I have text in a variable that I need to insert into a bunch of other files... The text is simple:
text='-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
This content is or could contain personal information. Please ensure that you are authorized to see this data! BLA BLA BLA!!!
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+'
Then , I do a simple:
sed "/##body/a $text" account_request_WHATEVER.vm
This searches for the ##body tag in the file and adds the variable text right after it... or so I thought...
Try escaping the <new line> chars when assigning the text variable:
text='-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\
This content is or could contain personal information.\
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+'
Please be aware that some sed versions NEED a \<new line> combination after the a command.
The awk doesn't do "something similar" - it's just seeing an unterminated string in your post.