Date: Tue, 30 May 2000 23:11:09 +0100 From: Mark Ovens <mark@ukug.uk.freebsd.org> To: Archie Cobbs <archie@whistle.com> Cc: Dan Nelson <dnelson@emsphone.com>, freebsd-questions@freebsd.org Subject: Re: basic sh(1) question Message-ID: <20000530231109.D229@parish> In-Reply-To: <200005302142.OAA76390@bubba.whistle.com>; from archie@whistle.com on Tue, May 30, 2000 at 02:42:57PM -0700 References: <20000530154228.C3419@dan.emsphone.com> <200005302142.OAA76390@bubba.whistle.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000530231109.D229>