From owner-freebsd-questions@FreeBSD.ORG Mon Sep 11 20:18:27 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 67AAF16A4A7 for ; Mon, 11 Sep 2006 20:18:27 +0000 (UTC) (envelope-from jan.grant@bristol.ac.uk) Received: from dirg.bris.ac.uk (dirg.bris.ac.uk [137.222.10.102]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E28043D5E for ; Mon, 11 Sep 2006 20:17:44 +0000 (GMT) (envelope-from jan.grant@bristol.ac.uk) Received: from mail.ilrt.bris.ac.uk ([137.222.16.62]) by dirg.bris.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1GMsBw-0005aR-NI; Mon, 11 Sep 2006 21:15:47 +0100 Received: from cse-jg.cse.bris.ac.uk ([137.222.12.37]:56195) by mail.ilrt.bris.ac.uk with esmtps (TLSv1:AES256-SHA:256) (Exim 4.50) id 1GMsBl-00011i-Tm; Mon, 11 Sep 2006 21:15:34 +0100 Date: Mon, 11 Sep 2006 21:15:23 +0100 (BST) From: Jan Grant X-X-Sender: cmjg@tribble.ilrt.bris.ac.uk To: "hackmiester (Hunter Fuller)" In-Reply-To: <618126D6-E8CC-4603-8371-C469A2DD96AA@hackmiester.com> Message-ID: <20060911205834.S63943@tribble.ilrt.bris.ac.uk> References: <45016BBC.8080803@kth.se> <618126D6-E8CC-4603-8371-C469A2DD96AA@hackmiester.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spamassassin: mail.ilrt.bris.ac.uk X-Spam-Score: 0.0 X-Spam-Level: / X-Spam-Score: -1.2 X-Spam-Level: - Cc: lassee@kth.se, freebsd-questions@freebsd.org Subject: Re: How do I give 2 parameters to programs in an unix enviroment? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Sep 2006 20:18:27 -0000 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