Path: utzoo!utgpu!watmath!att!pacbell!ames!lll-winken!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: sed behaves differently when run in backquotes/subshell Keywords: `sed`, sh, microport_system_V/AT Message-ID: <2985@solo12.cs.vu.nl> Date: 7 Aug 89 17:38:26 GMT References: <350@tree.UUCP> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 26 stever@tree.UUCP (Steve Rudek) writes: \... \GUESSES=`cat .TST | sed 's/\(.\)/\1\ \/g'|sort|paste -s -d"\0" -` Inside backquotes escaped newlines are removed... Now sed `sees' the following argument: s/\(.\)/\1/g To protect the escaped newline: ... | sed 's/\(.\)/\1\\ That's right: ONE extra backslash suffices - newlines are left undisturbed inside single quotes. In general, to debug pipe lines try something like: GUESSES=`cat .TST | echo sed 's/\(.\)/\1\ /g' > /dev/tty | sort | ...` i.e. just insert "echo" and "> /dev/tty" to see what the funny stuff expands to. -- "Mom! Eric Newton broke the day! In 24 |Maarten Litmaath @ VU Amsterdam: parts!" (Mike Schmitt in misc.misc) |maart@cs.vu.nl, mcvax!botter!maart