I’m curious, why does sed need 3 \ just to recognize one? I’d understand it needing 2, but 3 I don’t.
EDIT: here’s an example on my Windows computer, using Cygwin:
$ echo "sample_input\whatever" | sed "s/\\\/\//"
sample_input/whatever
If I don’t add 3 backslashes, I get a
sed: -e expression #1, char 7: unterminated s' command
I was able to reproduce this behavior using Vista and Cygwin 1.7.0.
Two backslashes become a single backslash in the shell which then in sed escapes the forward slash which is the middle delimiter.
Three of them: The first two become one in the shell which then escape the third one in sed
Four: Each pair become single ones in the shell then the first resulting one escapes the second in sed
Edit:
Oh, I forgot to say that both single quotes and double quotes worked the same for me (
cmd.exedoesn’t make the distinction that Bash, et al, makes).