replace (sed?) a string in file with multiple lines (string) from variable

Can someone tell me how I can do this?

e.g:

a=$(echo -e wert trewt ertert ertert ertert erttert
erterte
rterter
tertertert
ert)

How do i replace the STRING with $a?

I try this:

sed -i 's/STRING/'"$a"'/g' filename.ext

but this don' t work

Thanks for your help!

Hi,

Use double quotes for the entire 'sed' command.

$ sed -i "s/STRING/$a/g" filename.ext

Regards,
Birei

1 Like

I try double quotes but don't work

In my case
a=$(ewrwertwer trt erter ter ter tyer terter terter ter (werrewr) rwerwer werwer
asdas asd asd asd
werwerrwe�� w��)