Let's say I have the following variable:
var='a foo\nb bar\nc something'
Now I wan't to for example replace lines that contain 'bar' with '1 bar'. But keep in mind, that I want to keep my line feed signs, so I can save the output in a variable again. The result should look like:
$ echo $var2
a foo\n1 bar\nc something
I have tried to do it with Sed but the line feeds get replaced with spaces when I'm storing the output of Sed in a variable.