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.

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 stackoverflow.com Jun 11 '10 at 13:05

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

1 Answer 1

up vote 9 down vote accepted

Use the -xdev argument to find

-xdev Don’t descend directories on other filesystems.

share|improve this answer
1  
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 at 9:58

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.