Piping stderr in Korn and/or Bourne shell

Leo Willems leo at atcmp.nl
Sun Apr 8 05:22:35 AEST 1990


>From article <3620 at hcx1.SSD.CSD.HARRIS.COM>, by brad at SSD.CSD.HARRIS.COM (Brad Appleton):
> 
> I have a program that is supposed to read error output from other
> programs. I want to pipe stderr to this program WITHOUT piping
> stdin as well. I have not been able to find this in TFM (I have 
......
> I was hoping one of these last two might give me the output:
> 
>     this is stdout
>     this is STDerr
> 
> without piping stdin at all (just stderr)

Try this:

prog 3>&2 2>&1 1>&3 3>&- | sed 's/std/STD/'

This will swap stdout/stderr.

If you know a little C under UNIX it says:

prog close_3_dup_2 close_2_dup_1 close_1_dup_3 close_3 | sed


Hope this helps.


 Leo Willems			Internet: leo at atcmp.nl
 AT Computing			UUCP:     mcvax!hp4nl!kunivv1!atcmpe!leo
 P. O. Box 1428				
 6501 BK  Nijmegen		Phone:    +31-80-566880
 The Netherlands		Fax:	  +31-80-555887



More information about the Comp.unix.questions mailing list