Date: Mon, 11 Sep 2006 21:15:23 +0100 (BST) From: Jan Grant <jan.grant@bristol.ac.uk> To: "hackmiester (Hunter Fuller)" <hackmiester@hackmiester.com> Cc: lassee@kth.se, freebsd-questions@freebsd.org Subject: Re: How do I give 2 parameters to programs in an unix enviroment? Message-ID: <20060911205834.S63943@tribble.ilrt.bris.ac.uk> In-Reply-To: <618126D6-E8CC-4603-8371-C469A2DD96AA@hackmiester.com> References: <45016BBC.8080803@kth.se> <618126D6-E8CC-4603-8371-C469A2DD96AA@hackmiester.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 11 Sep 2006, hackmiester (Hunter Fuller) wrote: > On 8 September 2006, at 08:10, Lasse Edlund wrote: > > > If I have two files "foo" and "bar" and try to run diff on them I write: > > $diff foo bar > > I can also write > > $cat foo | diff - bar > > But how do I give a program two (2) commands? not only to diff > > but to any program that wants double input... > > I wanna do > > $cat foo | cat bar | diff - - > > The entire purpose of cat is to concatenate files (make them output one after > another). So, do: > > cat foo bar | diff - - This advice is wrong. To answer the original question: the shell pipe connects the stdout of the first process to the stdin of the second process using a pipe. The stock shells don't have a way of doing what you're after. If you have fdescfs mounted, ksh can do something like what you're after using the syntax: diff <(cat foo) <(cat bar) zsh supports something similar and can work around the lack of fdescfs. -- jan grant, ISYS, University of Bristol. http://www.bris.ac.uk/ Tel +44 (0)117 3317661 http://ioctl.org/jan/ ( echo "ouroboros"; cat ) > /dev/fd/0 # it's like talking to yourself sometimes
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060911205834.S63943>