duk@ace.UUCP (Duk Bekema) (10/16/87)
I have some questions about the V.2 Bourne shell. The following line: echo /other/duk | sed -e 's/\//\\/g' prints \other\duk So far, so good. Now I want to assign this to a shell variable, so I try msdos=`echo /other/duk | sed -e 's/\//\\/g'` This prints sed: command garbled: s/\//\/g ^ note the backslash Why doesn't it print sed: command garbled: s///\/g Since an extra shell is invoked for evaluating the command between backquotes, I thought every backslash had to be doubled, since the additional shell strips of the single quotes. However, the commands msdos=`echo /other/duk | sed -e 's/\//\\\/g'` echo $msdos and msdos=`echo /other/duk | sed -e 's/\\//\\\\/g'` echo $msdos both produce \other\duk If I set the -x flag, I see that in both cases the command s/\//\\/g is passed to sed. Can anyone explain this to me? Is there someone who can try this on a V7 or 4.xBSD Bourne shell? Please mail responses to me, I'll post a summary to the net. -- Duk Bekema ...!{seismo|decvax|philabs}!mcvax!ace!duk