slashes in a bash shell

Substituting the / for the \ I came up with this:

sed s/\\\\usr\\\\qm/\\\\\\\\qmi/g

Can anyone explain to me please, why I have to pass the slash four times?

:confused:

Backslash is special to the shell. It quotes the next character. For example:
echo ;
will not work because the shell sees the semicolon as a separator and will not pass it to the echo command. So to echo a semicolon we need to do:
echo \;
But what if we wanted to echo a backslash? We then we need to do this:
echo \\

So your four backslashes are needed just to deliver two backslashes to the sed program.

But sed also uses the backslash specially. And so if you really want sed to use a backslash as an ordinary character, you need to feed sed a double backslash as well.

If it makes you feel any better, 8 backslashes is no record.

i realise that the backslash was special, it just took me ages to figure out the combination and I didn't realise that they accumulate.

thanks again.