LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 03:19 PM   #1
da1
Member
 
Registered: May 2007
Distribution: FreeBSD
Posts: 113

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, 03:30 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

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

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

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



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 06:30 AM
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 11:26 AM
giving search-string(s) from a file to linux "find" command Fond_of_Opensource Linux - Newbie 3 02-02-2009 06:14 PM
[SOLVED] Why "apt-file search wx-config" not find? (Debian Lenny) kaz2100 Debian 4 01-02-2009 11:38 AM
How to tell wine where to find "Documents and Settings" folder? mschrank Linux - Software 1 11-29-2008 02:17 PM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 12:55 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration