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.

Is there a way to perform a find command on my whole computer, excluding external hard drives? I've been using the find command to search for junk left over from uninstalled software, like (from the top of the directory):

sudo find -iname . "*badexample*"

I'm confident there's nothing I'm looking for on my external drive. I suppose I could simply disconnect it before doing the find, but I'm curious how I might specify such an exclusion with bash. I'm also a little confused about where the external drive is located in the directory as well; /Volumes contains an alias that points to the drive, but it looks (using Get Info in Finder) like it points to itself.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

From the man page:

-mount Don’t descend directories on other filesystems.

Use this to see it yourself:

man find | less -p "-mount"

Of course this will prevent find from descending into ANY other filesystems, not just the one USB drive you are attempting to exclude.

Alternatively, you can do this. It won't save time and it WILL still search the USB drive, but will not display those particular results:

find / -name "badpattern" | grep -v "/path/to/USB_DRIVE"

share|improve this answer
    
I had to do a little digging (version of find on my computer uses -x instead of -mount), but this worked. Excellent! Thank you! –  ivan Oct 3 '12 at 22:38
    
Many Linux programs use -x (like du for example). The find command also allows -xdev in addition to -mount. They both do the same thing. –  UtahJarhead Oct 4 '12 at 12:24
add comment

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.