Use -prune to skip directory while finding file
paul
posted @ Fri, 12 Jun 2009 18:24:24 +0800
in coding life
, 1322 readers
To ignore a whole directory tree, use -prune rather than checking every files in it.
find \( -path '<directory-to-skip>' -o -path '<another-directory-to-skip>' \) -prune -o -print
Furthermore, take the file nams in consideration.
find \( -path '<directory-to-skip>' -o -path '<another-directory-to-skip>' \) -prune -o -name '<file-name-pattern>' -print
This trick really saves me couple of time when I do a find in a large filesystem.
This work is licensed under a Creative Commons Attribution 3.0 Unported License.