The dot in ... --- ...

Chris Gerhard's Weblog

« Installing support... | Main | Another update to... »

20090508 Friday May 08, 2009

Stopping find searching remote directories.

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

simple.


( May 08 2009, 03:57:16 PM BST ) Permalink Trackback

   
Comments:

Ah. Nice reminder.

It is also nice to exclude virtual filesystems too:

find / \( ! -fstype ufs -prune \) -o \( ! -fstype zfs -prune \) -o -print

Posted by Steve Logue on May 08, 2009 at 08:41 PM BST #

As *easy* as it is, it's still the damnedest concatenation to spill from ones fingers. Specially considering the amount of times one wishes to use this when looking for something from / (root).

Posted by Stacey Marshall on May 09, 2009 at 10:46 AM BST #

/kill find or /kill -9 find

Posted by jfewkew on May 16, 2009 at 07:00 PM BST #

Post a Comment:

Comments are closed for this entry.

Valid HTML! Valid CSS!

Except where otherwise noted, this site is
licensed under a Creative Commons License 2.0

This is a personal weblog, I do not speak for my employer.