How do I give 2 parameters to programs in an unix enviroment?

Dan Nelson dnelson at allantgroup.com
Fri Sep 8 07:28:51 PDT 2006


In the last episode (Sep 08), David King said:
> Here's an example using zsh (I assume it's the same using bash, but
> different using tcsh or sh):
> 
> diff <(find /usr/local -type f | sort) <(for each in /var/db/pkg/*/ 
> +CONTENTS; do grep -v '^@' $each; done | sort)
> 
> This does a diff(1) of what /var/db/pkg says that /usr/local should
> look like, and what it *really* looks like (note that it would need
> some tuning in order to actually be useful, but you get the idea)
> 
> This uses the <() operator. What the <() operator does is create a
> named pipe in /tmp, execute the commands contained in the parenthesis
> in a subshell, and connect the stdout of the subshell into that named
> pipe. So it's sort of like using temp files, but you don't have to
> clean up after yourself. There's another, similar operator that does
> force it to use temp files, but I can never remember what it is :)
> Check the manpages for your shell

Just for the archives, The =() operator puts the output to a temp file
and returns the filename to the main command.  It has to wait for the
subshell to finish before running the main command, though.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list