Why use find? (Was: Can U pipe filenames to rm???)

Conor P. Cahill cpcahil at virtech.uucp
Sat Oct 6 11:14:38 AEST 1990


In article <1990Oct5.145825.9454 at diku.dk> kimcm at diku.dk (Kim Christian Madsen) writes:
>george at hls0.hls.oz (George Turczynski) writes:
>
>>Why use `xargs' when you don't need to ?
>
>There are a lot of uses of xargs that are superior to using find with the
>exec option. Find is *SLOW*, so if you have the names of files you want to
>do something with in a file or pipe use xargs for performance.

Find, in itself, is not slow.  The exec of a new process (the rm in this
case) for every file found is *SLOW*.  Obviously, if you already have the
list of files you don't need to run find to get them again. 

>Find is also complicated to use for non-trivial tasks, and the syntax  is
>often confusing to non-wizards, so specialized shell-scripts or programs
>are often more intuitive and faster to create and maintain.

This is getting into a typical religous issue, so I won't say much in
response other than the fact that if someone knows enough about the system
to creat shell scripts and/or programs it behooves them to take an 
extra few minutes to learn find.

Find in itself is not complicated (just some name selection logic) and 
should be one of the tools that anyone writing shells is intimately aware
of.  (BTW - I am one of the people that believe you shouldn't be allowed
to write any shell scripts until you have made a complete pass through
sections 1 & 1m (or 8, depending upon your OS) AND you should repeat this
on a regular basis).

As an aside, most of the specialized shell scripts that you mentioned will
usually run a find as part of the script anyway.

>All this is not to bash find(1), which is a wonderful, general tool, however
>the multitude of UNIX tools gives you the choice of selecting the one,
>most appropriate for your task and the one you're most familiar with.

But to make the correct selection you should be aware of most, if not
all, of the tools available (nothing is better than an educated decision).


-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 



More information about the Comp.unix.shell mailing list