I have a string S, for which I want to replace every b character with \\ (two forward slashes).
So this is what I have:
$ S="abc"
$ A=$(echo $S | sed 's/b/\\\\/')
In bash I get the expected output:
$ echo $A
a\\c
but in zsh I have
$ echo $A
a\c
It seems to me that zsh's behavior is unexpected, why does it behave this way?
I want A to contain two forward slashes (so I can use it later as a regex, for example). How can I achieve this in a cross-shell way?