Replace a blank space with string "\\ "

Hi,
I have a requirement to replace a every blank space with char "\\ ".
Like string "God Love" to "God\\ Love"
and "God Love" as "God\\ \\ Love".
and only in the sed.

We have already a script but it is replaceing all continuous blank space with one "\\ ". which is as
DIR=`sudo echo $INSTALL| cut -f1 -d'/'|sed 's/ /\(\\\)\(\\\)\(\\\)\(\\\) /g'|sed 's/(//g'|sed 's/)//g'`

here $INSTALL is as input .

echo 'a  b' | sed 's/ /\\\\ /g'

thanks,
but in my input i don't know how many blank space..
Should it work in that case also..

Also can u explane me the following line

DIR=`sudo echo $INSTALL| cut -f1 -d'/'|sed 's/ /\(\\\)\(\\\)\(\\\)\(\\\) /g'|sed 's/(//g'|sed 's/)//g'`

Have you tried what'd been posted?

Not yer. I have not unix system at home. I will try it in office.

I would appreciate if any one explain me these

DIR=`sudo echo $INSTALL| cut -f1 -d'/'|sed 's/ /\(\\\)\(\\\)\(\\\)\(\\\) /g'|sed 's/(//g'|sed 's/)//g'`

The easiest way is to 'step' through the pipes one at the time:

$ echo 'a 1 2 3/b/c/d' | cut -f1 -d'/'
a 1 2 3

$ echo 'a 1 2 3/b/c/d' | cut -f1 -d'/' | sed 's/ /\(\\\)\(\\\)\(\\\)\(\\\) /g'
a(\)(\)(\)(\) 1(\)(\)(\)(\) 2(\)(\)(\)(\) 3


$ echo 'a 1 2 3/b/c/d' | cut -f1 -d'/' | sed 's/ /\(\\\)\(\\\)\(\\\)\(\\\) /g' | sed 's/(//g'
a\)\)\)\) 1\)\)\)\) 2\)\)\)\) 3


$ echo 'a 1 2 3/b/c/d' | cut -f1 -d'/' | sed 's/ /\(\\\)\(\\\)\(\\\)\(\\\) /g' | sed 's/(//g' | sed 's/)//g'
a\\\\ 1\\\\ 2\\\\ 3

thanks a lot vgersh99