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

Leslie Mikesell les at chinet.chi.il.us
Fri Oct 12 01:38:29 AEST 1990


In article <5069:Oct903:10:1390 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:

>But who said there's a tty around? What if Pim wanted to pipe his output
>through yet another command?
>
>  ( exec 5>&1; exec 1>&2; exec 2>&5; foo ) | err-processor
>
>Even you :-) should be able to recognize the swap idiom there. Start
>from basic constructs like this and soon you'll be piping stdout and
>stderr through separate commands. Someday you may even learn to use
>multitee... [grin]

Or FIFO's  (which might even be available on his machine...)

/etc/mknod /tmp/fifo$$ p
err-processor < /tmp/fifo$$ &
command 2>/tmp/fifo$$ | output_processor
rm /tmp/fifo$$

Straightforward enough, and err-processor would not even be required to have
a common parent with the rest of the programs if they have some way
of determining the name to use.

Les Mikesell
  les at chinet.chi.il.us



More information about the Comp.unix.shell mailing list