From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2002 invoked from network); 24 Oct 1997 15:03:57 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 24 Oct 1997 15:03:57 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id KAA08876; Fri, 24 Oct 1997 10:59:28 -0400 (EDT) Resent-Date: Fri, 24 Oct 1997 10:59:10 -0400 (EDT) Message-Id: <199710241500.RAA11438@hydra.ifh.de> To: zsh-users@math.gatech.edu (Zsh users list) Subject: Re: Redirect &2 into a command - HowTo In-reply-to: "Helmut Jarausch"'s message of "Fri, 24 Oct 1997 16:36:52 MST." Date: Fri, 24 Oct 1997 17:00:00 +0200 From: Peter Stephenson Resent-Message-ID: <"6hQXI.0.o92.zUBKq"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1099 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Helmut Jarausch wrote: > Sorry if this is a FAQ (I didn't find it there). You may find it in the general shell FAQs; it'll work in any proper shell (i.e. not csh, tcsh). > Is there any possibility to redirect STDERR to a command like 'xless' > without redirecting STDOUT as well? The trick is to use a spare FD to swap the first two. mycmd 3>&1 1>&2 2>&3 3>&- | xless which means 1) open a new fd 3 to stdout (the pipe) 2) redirect stdout to where stderr is 3) now move stderr to 3, which is the original stdout 4) to be tidy, close the spare fd, though in this case that's not actually necessary (I won't bore you). One important extra which isn't in anyone else's FAQ: in zsh, you need to `setopt nomultios', since a `multio' will interpret the `1>&2' as saying you want stdout to go to both the old stderr *and* the pipe, which in this case you don't. (Do we need an option `pipemultios', which is off by default?) -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413 Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, Platanenallee 6, 15738 Zeuthen, Germany.