Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!uunet!mcsun!ukc!pyrltd!tetrauk!rick From: rick@tetrauk.UUCP (Rick Jones) Newsgroups: comp.unix.shell Subject: Re: How to pipe stderr to a command in Bourne or Korn shell Message-ID: <761@tetrauk.UUCP> Date: 9 Oct 90 10:05:09 GMT References: <1990Oct8.165133.17187@cti-software.nl> <6133@ge-dab.GE.COM> <1990Oct8.204053.15797@athena.mit.edu> <3207@idunno.Princeton.EDU> Reply-To: rick@tetrauk.UUCP (Rick Jones) Organization: Tetra Ltd., Maidenhead, UK Lines: 21 In article <3207@idunno.Princeton.EDU> pfalstad@flower.Princeton.EDU (Paul John Falstad) writes: >In article <1990Oct8.204053.15797@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes: >>|> |> How can one redirect stderr to a command while leaving stdout unaffected ? > >In bash, sh, and (I'm fairly sure) ksh, you can do this and avoid the >subshell: > >program 2>&1 >/dev/tty | command In sh, file descriptor re-directions are evaluated left to right, so you can even swap stdout & stderr with a little care & avoid /dev/tty if you want: program 3>&2 2>&1 >&3 | command I think this should work in ksh, but doesn't seem to in my version - a buglet? I can't speak for bash as I don't use it. -- Rick Jones The definition of atomic: Tetra Ltd. from the Greek meaning "indivisible" Maidenhead, Berks, UK So what is: rick@tetrauk.uucp an atomic explosion?