Q:
I want to run
find
across a directory tree, skipping standard directories like
/usr/spool
and
/usr/local/bin
. A
-name
dirname
-prune
clause won't do it because
- name
doesn't match the whole pathname - just each part of it, such as
spool
or
local
. How can I make
find
match the whole pathname, like
/usr/local/bin/
, instead of
all
directories named
bin
?
A: It cannot be done directly. You can do this:
A:
test |
find / |
---|
A:
This will not perform
pred
on
/foo/bar
and
/foo/baz
; if you want them done, but not any files within them, try:
A:
findpath
\( -exec testtest-exprs
\; ! -prune \) -opred
A: The second version is worth close study, keeping the manual for find at hand for reference. It shows a great deal about how find works.
A: The -prune operator simply says "do not search the current path any deeper," and then succeeds a la -print .
-
,