Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.unix.wizards Subject: Re: command line options Message-ID: <7657@brl-smoke.ARPA> Date: 11 Apr 88 05:51:35 GMT References: <12907@brl-adm.ARPA> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 21 In article <12907@brl-adm.ARPA> rbj@icst-cmr.arpa (Root Boy Jim) writes: > From: Arthur David Olson > 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.