Why doesn't 'find' prune the way I think it should?
Try this:
find -type d -path '.svn' -prune -o -print
From man find
under the section on -name
:
To ignore a directory and the files under it, use
-prune
; see an example in the description of-path
.
Under the section on -path
:
To ignore a whole directory tree, use
-prune
rather than checking every file in the tree. For example, to skip the directorysrc/emacs
and all files and directories under it, and print the names of the other files found, do something like this:find . -path ./src/emacs -prune -o -print
From the "Examples" section:
However, the
-prune
action itself returns true, so the following-o
ensures that the right hand side is evaluated only for those directories which didn't get pruned (the contents of the pruned directories are not even visited, so their contents are irrelevant).
find manual states tha prune "ignores the preceding path ..." so the command should be
find . -prune -type d -name '*svn'
This is because you can have something like
find -path . -name '*svn' -o -path './notimportantdir' -prune
which finds '*svn' in current path except those under notimportantdir