How to pipe stderr to a command in Bourne or Korn shell

Rick Jones rick at tetrauk.UUCP
Tue Oct 9 20:05:09 AEST 1990


In article <3207 at idunno.Princeton.EDU> pfalstad at flower.Princeton.EDU (Paul John Falstad) writes:
>In article <1990Oct8.204053.15797 at athena.mit.edu> jik at 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 at tetrauk.uucp			an atomic explosion?



More information about the Comp.unix.shell mailing list