command line options
Doug Gwyn
gwyn at brl-smoke.ARPA
Mon Apr 11 15:51:35 AEST 1988
In article <12907 at brl-adm.ARPA> rbj at icst-cmr.arpa (Root Boy Jim) writes:
> From: Arthur David Olson <ado at elsie.uucp>
> Pike's Position is that
> Programs that accept multiple filenames
> should do nothing if given no arguments.
> This ensures that if you use a command such as
> cat `find * -type f -print`
> to concatenate all the files in a directory and its subdirectories,
> you won't get surprised when there are NO files in the directory and
> cat starts reading from its standard input.
>Add /dev/null to the end.
The /dev/null trick is worth knowing, especially when using xargs to
grep a large number of files.
There is something to be said for a "regular" "cat" and something
to be said for the usual "cat". The "regular" one is less surprising
and easier to use in building tools, but the usual one finds frequent
use at the head of a pipeline in shell scripts:
cat $* | ...
I think this trick is even in Kernighan & Pike.
More information about the Comp.unix.wizards
mailing list