LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices

Reply
 
Search this Thread
Old 04-12-2009, 04:19 PM   #1
da1
Member
 
Registered: May 2007
Distribution: FreeBSD
Posts: 110

Rep: Reputation: 16
"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.
 
Old 04-12-2009, 04:30 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Code:
find / -wholename /mnt -prune -o -name my_file -print
See this post for a detailed explanation.
 
Old 04-12-2009, 04:41 PM   #3
da1
Member
 
Registered: May 2007
Distribution: FreeBSD
Posts: 110

Original Poster
Rep: Reputation: 16
thx...
 
Old 04-12-2009, 05:08 PM   #4
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 476
Blog Entries: 119

Rep: Reputation: 74
-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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to tell "find" to not search inside hidden folders? robo555 Linux - General 8 08-08-2011 07:30 AM
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 12:26 PM
giving search-string(s) from a file to linux "find" command Fond_of_Opensource Linux - Newbie 3 02-02-2009 07:14 PM
Why "apt-file search wx-config" not find? (Debian Lenny) kaz2100 Debian 4 01-02-2009 12:38 PM
How to tell wine where to find "Documents and Settings" folder? mschrank Linux - Software 1 11-29-2008 03:17 PM


All times are GMT -5. The time now is 11:59 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration