Stopping find searching remote directories.
By user12625760 on May 08, 2009
Grizzled UNIX users look away now.
The find command is a wonderful thing but there are some uses of it that seem to cause confusion enough that it seems worth documenting them for google. Today's is:
How can I stop find(1) searching remote file systems?
On reading the documentation the “-local” option should be just what you want and it is, but not on it's own. If you just do:
$ find . -local -print
It will indeed only report on files that are on local file systems below the current directory. However it will search the entire directory tree for those local files even if the directory tree is on NFS
To get find to stop searching when it finds a remote file system you need:
$ find . \\( ! -local -prune \\) -o -print