Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Sep 2006 09:18:05 -0400
From:      "Matt Emmerton" <matt@gsicomp.on.ca>
To:        <lassee@kth.se>, <freebsd-questions@freebsd.org>
Subject:   Re: How do I give 2 parameters to programs in an unix enviroment?
Message-ID:  <005401c6d349$3897bea0$0000fea9@gsicomp.on.ca>
References:  <45016BBC.8080803@kth.se>

next in thread | previous in thread | raw e-mail | index | archive | help

> 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 - -
> especially with echo commands that would be handy so I dont have to
> create files!

You don't.  Recall that | is the "pipe" operator, and like in real life,
there's one input and one output.

Pipes used on the command line are for all intents and purposes "unnamed",
and you can only build up one "pipeline".
That's why named pipes were invented, so that you could have multiple pipes
and refer to them by name (instead of implicitly).

But in your case, using named pipes is really no different than using files.

--
Matt Emmerton




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?005401c6d349$3897bea0$0000fea9>