How can escape the literal string #!/bin/bash in a sed expression? Curently I have a command in a bash script of the form
sed 's/Parametersettings:/HERE/g' outpad1 > outpad2I would like the escaped replacement to go where HERE is written in the above.
I have tried all sorts of / \ and $variables with no luck so far.
2 Answers
$ echo 'Parametersettings:' | sed 's/Parametersettings:/#!\/bin\/bash/g'
#!/bin/bashor use a different delimiter, avoiding the need to escape the / characters:
$ echo 'Parametersettings:' | sed 's%Parametersettings:%#!/bin/bash%g'
#!/bin/bash 0 By quoting your string with single quotes ("''"), you PREVENT interpolation by the shell. Use double quotes ("") and the shell will substitute variables, etc.
sed "s/Parametersettings:/$HERE/g" outpad1 > outpad2