#
and =
are not RE metacharacters nor do they have any other special meaning to sed within a regexp (=
does outside of a regexp) unless the regexp is delimited with one of them so there's no reason to escape them in your script. '
only has significance if the whole script is delimited with '
s since in shell no script that's delimited by a given character can include that character. So here's your choices:
$ echo "seab'cd" | sed 's/b'\''c/foo/'
seafood
$ echo "seab'cd" | sed "s/b'c/foo/"
seafood
Note that if you use the second (double quotes) version then you're allowing shell variables to expand inside the script and would require double-backslashes to escape chars.
I expected using the octal representation of a '
(i.e. \047
) would work too like it does in awk:
$ echo "seab'cd" | awk '{sub(/b\047c/,"foo")}1'
seafood
but it didn't:
$ echo "seab'cd" | sed 's/b\047c/foo/'
seab'cd
and I suspect that's because sed is treating \0
as a backreference. It does work with the hex representation:
$ echo "seab'cd" | sed 's/b\x27c/foo/'
seafood
but that's dangerous and should be avoided (see http://awk.freeshell.org/PrintASingleQuote).