🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1433

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

#1433
From: Dan Bernstein
Date: Tue, 09 Oct 1990 03:10
22 lines
1459 bytes
In article <1990Oct8.204053.15797@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes:
>   In csh, one possible way to do it (when working at a tty) would be:

But who said there's a tty around? What if Pim wanted to pipe his output
through yet another command?

> 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 :-):

I use the bourne shell a lot, so I guess I qualify. It isn't too
hideous, though, if you write it clearly:

  ( 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]

---Dan
Technical Details
Message-ID: <5069:Oct903:10:1390@kramden.acf.nyu.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!yale!cmcl2!kramden.acf.nyu.edu!brnstnd
References: <1990Oct8.165133.17187@cti-software.nl> <6133@ge-dab.GE.COM> <1990Oct8.204053.15797@athena.mit.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!yale!cmcl2!kramden.acf.nyu.edu!brnstnd
From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein)
Newsgroups: comp.unix.shell
Subject: Re: How to pipe stderr to a command in Bourne or Korn shell
Message-ID: <5069:Oct903:10:1390@kramden.acf.nyu.edu>
Date: 9 Oct 90 03:10:13 GMT
References: <1990Oct8.165133.17187@cti-software.nl> <6133@ge-dab.GE.COM> <1990Oct8.204053.15797@athena.mit.edu>
Organization: IR
Lines: 22