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

Paul Chamberlain tif at doorstop.austin.ibm.com
Wed Oct 10 08:23:47 AEST 1990


In article <3002 at wyse.wyse.com> bob at wyse.UUCP (Bob McGowen x4312 dept208) writes:
>In article <1990Oct8.165133.17187 at cti-software.nl>, pim at cti-software.nl writes:
>> How can one redirect stderr to a command while leaving stdout unaffected ?
>The question was how to redirect to a command, not a file.  You might think
>that something like 2| would work, but it doesn't (at least in sh, I have
>no ksh to try it on).
>
>I have tried several permutations of re-ordering file descriptors and trying
>to use new ones with the _exec- builtin but have had no success yet.

Just thought I'd take a stab at it.  There may be a better way.
I use Korn Shell.

$ echo now is the time > xx
$ rm -f zz
$ ( cat zz xx 2>&1 1>&3 | od -c ) 3>&1
now is the time
0000000   c   a   t   :       c   a   n   n   o   t       o   p   e   n
0000020       z   z  \n
0000024

Paul Chamberlain | I do NOT represent IBM.     tif at doorstop, sc30661 at ausvm6
512/838-7008     | ...!cs.utexas.edu!ibmaus!auschs!doorstop.austin.ibm.com!tif



More information about the Comp.unix.shell mailing list