From owner-freebsd-questions Tue May 30 15:11:10 2000 Delivered-To: freebsd-questions@freebsd.org Received: from monsoon.mail.pipex.net (monsoon.mail.pipex.net [158.43.128.69]) by hub.freebsd.org (Postfix) with SMTP id 34CF737B519 for ; Tue, 30 May 2000 15:11:07 -0700 (PDT) (envelope-from mark@dogma.freebsd-uk.eu.org) Received: (qmail 16350 invoked from network); 30 May 2000 22:11:04 -0000 Received: from userbg05.uk.uudial.com (HELO parish.my.domain) (62.188.142.125) by smtp.dial.pipex.com with SMTP; 30 May 2000 22:11:04 -0000 Received: (from mark@localhost) by parish.my.domain (8.9.3/8.9.3) id XAA01746; Tue, 30 May 2000 23:11:09 +0100 (BST) (envelope-from mark) Date: Tue, 30 May 2000 23:11:09 +0100 From: Mark Ovens To: Archie Cobbs Cc: Dan Nelson , freebsd-questions@freebsd.org Subject: Re: basic sh(1) question Message-ID: <20000530231109.D229@parish> References: <20000530154228.C3419@dan.emsphone.com> <200005302142.OAA76390@bubba.whistle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <200005302142.OAA76390@bubba.whistle.com>; from archie@whistle.com on Tue, May 30, 2000 at 02:42:57PM -0700 Organization: Total lack of Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, May 30, 2000 at 02:42:57PM -0700, Archie Cobbs wrote: > Dan Nelson writes: > > > In sh(1), how do I make both the stdout and stderr output of a command > > > get piped together into another command? > > > > > > For output to a file, you do this: > > > > > > $ cmd1 >file 2>&1 > > > > > > So you'd think the same thing would work for output to another command, > > > but it doesn't: > > > > > > $ cmd1 |cmd2 2>&1 > > > > That line redirects stderr to stdout for "cmd2", since the redirection > > is after the command. "cmd1 2>&1 | cmd2" should do what you want. > > Hmm... kindof non-intuitive though, eh? Not really. The redirection applies to a single command (each command has it's own output streams), not the "compound" pipeline. You wanted to merge stdout and stderr from the *first* command, not the second. > Because doing this doesn't work: > > $ cmd1 2>&1 >file > Because ``2>&1'' says "send the output from stderr to stdout and ``>file'' says redirect stdout to file. However, ``2>&1'' doesn't permanently "bind" stderr to stdout, IOW redirecting stdout after stderr doesn't redirect both. > Oh, whatever.. in any case, thanks for the help. > > -Archie > > ___________________________________________________________________________ > Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message -- ...and on the eighth day God created UNIX ________________________________________________________________ FreeBSD - The Power To Serve http://www.freebsd.org My Webpage http://ukug.uk.freebsd.org/~mark/ mailto:mark@ukug.uk.freebsd.org http://www.radan.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message