Case example:
So the resulting variable stores some characters, like new line ones:
When I try to replace a string with this variable:
This is supposed to occur with any special character, like "\", "|", "*", "%"... etc.
How could I solve it, so no value inside the variable will become a problem and the replacement is done all right?
Bash:
$ variable="$(ls -la)"
So the resulting variable stores some characters, like new line ones:
Bash:
$ echo "$variable"
total 8
drwxr-xr-x 2 luis wheel 512 May 27 04:15 .
drwxrwxrwt 15 root wheel 1536 May 27 04:15 ..
When I try to replace a string with this variable:
Bash:
$ echo "Replacement will be HERE after sed" | sed "s/HERE/$variable/g"
sed: 1: "s/HERE/total 8
drwxr-xr ...": unescaped newline inside substitute pattern
This is supposed to occur with any special character, like "\", "|", "*", "%"... etc.
How could I solve it, so no value inside the variable will become a problem and the replacement is done all right?