Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!mcvax!ace!duk From: duk@ace.UUCP (Duk Bekema) Newsgroups: comp.unix.questions Subject: System V.2 Bourne shell question Message-ID: <446@ace.UUCP> Date: Fri, 16-Oct-87 04:44:04 EDT Article-I.D.: ace.446 Posted: Fri Oct 16 04:44:04 1987 Date-Received: Sun, 18-Oct-87 09:27:11 EDT Sender: news@ace.UUCP Organization: ACE Associated Computer Experts bv, Amsterdam Lines: 37 Keywords: backslash 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