Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Sep 2006 07:18:10 -0700 (PDT)
From:      backyard <backyard1454-bsd@yahoo.com>
To:        lassee@kth.se, freebsd-questions@freebsd.org
Subject:   Re: How do I give 2 parameters to programs in an unix enviroment?
Message-ID:  <20060908141810.8314.qmail@web83106.mail.mud.yahoo.com>
In-Reply-To: <45016BBC.8080803@kth.se>

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


--- Lasse Edlund <lassee@kth.se> 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 - -
> especially with echo commands that would be handy so
> I dont have to
> create files!
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
>
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe@freebsd.org"
> 

diff foo bar
is the the way a contruct like
(cat foo; cat bar| diff - -)
may work but I doubt it because they both are writing
to the same STDOUT and so "- -" is more then likely
invalid.

(echo "random junkola" > foo) && (cat foo > bar)
or
(echo "random junkola" > foo) && (cp foo bar)
would be just as good.
would echo the same thing to two files. 

I think what you want might be 

diff `cat foo` `cat bar`

which is the the quote on the tilde key. check 
man eval

if I'm using the right quote this will evaluate the
command in the ` ` and pass its STDOUT as a parameter.
For large files this might fail because of the
limitation to the command line length, I'm not
certain.

the best thing might be look in /etc/rc for the last
line which will be something like:
echo `date`

those are the quotes you want and this is the only way
to do what I think you're asking.

-brian



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060908141810.8314.qmail>