🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1426

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

#1426
From: Jonathan I. Kamens
Date: Mon, 08 Oct 1990 20:40
25 lines
1661 bytes
In article <6133@ge-dab.GE.COM>, coleman@sunny.DAB.GE.COM (Richard Coleman) writes:
|> In article <1990Oct8.165133.17187@cti-software.nl>, pim@cti-software.nl (Pim Zandbergen) writes:
|> |> How can one redirect stderr to a command while leaving stdout unaffected ?
|> For csh and bash try       (command > temp1) >& temp2
|> For sh                      command 2> temp

  The original poster asked how to redirect to a *command*.  You've shown how
to redirect to a *file*.

  In csh, one possible way to do it (when working at a tty) would be:

    (program > /dev/tty) |& 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 :-):

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

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710
Technical Details
Message-ID: <1990Oct8.204053.15797@athena.mit.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!bloom-beacon!athena.mit.edu!jik
References: <1990Oct8.165133.17187@cti-software.nl> <6133@ge-dab.GE.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!bloom-beacon!athena.mit.edu!jik
From: jik@athena.mit.edu (Jonathan I. Kamens)
Newsgroups: comp.unix.shell
Subject: Re: How to pipe stderr to a command in Bourne or Korn shell
Message-ID: <1990Oct8.204053.15797@athena.mit.edu>
Date: 8 Oct 90 20:40:53 GMT
References: <1990Oct8.165133.17187@cti-software.nl> <6133@ge-dab.GE.COM>
Sender: daemon@athena.mit.edu (Mr Background)
Reply-To: jik@athena.mit.edu (Jonathan I. Kamens)
Organization: Massachusetts Institute of Technology
Lines: 25