Insert a new line after a pattern

Hi Team,

I have a req in which I have to variable 1. is the pattern string and the second is the string which I need to insert once I have that pattern.

Pattern="<name>$Name<\/name>"
InsertStr=<value>$Value<\/value>

Can we do this using sed/awk. if yes please help. I am trying to use a\ I am getting an error which says that unable to parse the message.
I used something like this and it is saying uable to parse the command.

sed -e /$Pattern/a$InsertStr $filePath

Please help

Please use code tags as required by forum rules!

I think you are not too far off. You don't mention your system nor sed version; some sed s insist on a newline to follow an a\ command. And, make sure that your pattern is really found in the filepath.

Hi Rudic
I am new and was not aware was this code tag means
However I got that now

I am using AIX 6
for

sed

version I tried doing a

sed -V

but got the error saying tag not identified.

man sed :

At a minimum, I would suggest enclosing the variable assignment and sed script in single quotes, as follows:

InsertStr="<value>$Value</value>"
sed "/$Pattern/a $InsertStr" $filePath

Do you really want <\/value> instead of </value> which I think is correct?