When I used the find command, I almost always need to search the local drives. But, I almost always have super large network shares mounted and these are included in the search. Is there an easy way to exclude those in the find command, grep and other similar commands? Example:

find / -name .vimrc

link|improve this question

feedback

1 Answer

up vote 7 down vote accepted

Use the -fstype local option to find:

find / -fstype local -name .vimrc

If you want to exclude only specific paths, you could use -prune:

find / -name /path/to/ignore -prune -o -name .vimrc

Update:

The local psuedo-fstype is available in the version of find that comes with OS X, but is not in GNU find (fstypes recognized by GNU find).

If you're using GNU find (as is used on most linux systems), you'll instead want to use -mount:

find / -mount -name .vimrc
link|improve this answer
does that work for grep too? – Flotsam N. Jetsam Jan 5 '11 at 15:36
1  
I don't think grep has such an option. I usually used find pipe to grep as shown in this answer: superuser.com/questions/80033/… . Lately, I've been using ack (betterthangrep.com) instead, but ack doesn't seem to have an option to search only local drives. – Doug Harris Jan 5 '11 at 15:43
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.