Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 10 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
share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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