sed behaves differently when run in backquotes/subshell

Conor P. Cahill cpcahil at virtech.UUCP
Tue Aug 8 10:23:04 AEST 1989


In article <350 at tree.UUCP>, stever at tree.UUCP (Steve Rudek) writes:
> I needed a shell script which would take strings of letters and alphabetize
> them into a single line and sed + sort seemed like the best choice.  But I find 
> that sed performs differently when part of a pipeline not explicitly in a
> subshell than it does when run in backquotes.  What's the problem?

  It is not set which mis-behaves, but the shell.  When you run in the `sub-shell`
  the "^j" is eaten by the shell command line processing.  A different mechanism
  would be to use the tilde instead of the <return> and then translate the 
  tilde to a <return>.  For ex:

	GUESSES=`cat .TST | sed 's/\(.\)/\1~/g' | tr "~" "\012" | sort....



More information about the Comp.unix.questions mailing list