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

Paul John Falstad pfalstad at flower.Princeton.EDU
Tue Oct 9 07:12:05 AEST 1990


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 ?
>A similar approach will work in sh (and probably ksh), although there's
>probably some better way to do it with various hideous file descriptor
>reassignments (I don't use the bourne shell a lot, so I don't qualify to
>invent hideous file descriptor reassignments :-):
>
>    (program > /dev/tty) 2>&1 | command

They're not that hideous!

In bash, sh, and (I'm fairly sure) ksh, you can do this and avoid the
subshell:

program 2>&1 >/dev/tty | command

--
     Are you nervy?  Irritable?  Depressed?  Tired of life?  Keep it up!



More information about the Comp.unix.shell mailing list