"find" exclude file/folder from search
Hello,
Here's a nice (idiotic) question. How to exclude a file/folder from search ? Case: We have a standard / . In / there exists /mnt that has several folders, each pointing to different hdd's. If one wants to search the / partition but not descend into /mnt, what would the corect command be ? Tryed some combination of "-prune, -path" but faile mizerably. Thx. |
Code:
find / -wholename /mnt -prune -o -name my_file -print |
thx...
|
-xdev, or, if you find it more readable, -mount.
Note, this is by side-effect that it doesn't descend into directories in /mnt. What -xdev/-mount do is stop "find" from descending into directories on other filesystems. If you have multiple mount points, you could: # for dir in `df -l | grep / | cut -d'%' -f2`; do find $dir <options> -xdev; done It'll launch multiple "find" processes, but it'll effectively exclude all remote filesystems. You also could figure out a way to negate -fstype arg to "find", but I couldn't seem to locate anything on that. |
All times are GMT -5. The time now is 10:49 PM. |