Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I need to do:

find / -name somefile.txt

and say root partition / is mounted on /dev/sda5; however, let's say I also have 250GB partitions (/dev/sda6, /dev/sda7) mounted in /media - AND another location that I cannot currently remember. Say, also, that I know the file I'm looking for is on /dev/sda5.

Obviously, the above command will also descend in /media and that other directory which represent the big partitions, wasting time in looking for the file in the wrong place.

Is there a way to instruct find (or other command) to search only / on /dev/sda5, and NOT to descend to directories if they are on different partitions?

share|improve this question

migrated from Jun 11 '10 at 13:05

This question came from our site for professional and enthusiast programmers.

up vote 11 down vote accepted

Use the -xdev argument to find

-xdev Don’t descend directories on other filesystems.

share|improve this answer
Thanks much - just for reference, the syntax would be: <pre>find / -xdev -name somefile.txt</pre> – sdaau Jun 11 '10 at 13:43
For mac users: find -x / -name somefile.txt – CodeReaper Jan 31 '14 at 9:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .