- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find but ignore one or two directories.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 05:45 AM
02-02-2009 05:45 AM
Can find be use in a script to search for a file, ( let's say core ) and yet ignore one or two directories you do not want to search.
I tried gfind, but what happens is that it shows all files with the core sting on them.
Any thoughts?
Thanks,
f. halili
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 06:08 AM
02-02-2009 06:08 AM
Re: find but ignore one or two directories.
For example you need to find core in /usr in FS but ignore /usr/local and /usr/etc we can use the below find command
find /usr -xdev -name "core" -path \(/usr/local -o /usr/etc\) -prune -o -print
Sagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 06:14 AM
02-02-2009 06:14 AM
Re: find but ignore one or two directories.
you can exclude with 'grep -v', see also 'man grep'.
find . -type f -name core|grep -v
Well, of course it exludes every path with the same string
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 06:39 AM
02-02-2009 06:39 AM
Re: find but ignore one or two directories.
I tried the syntax you gave but got the following below.
# /usr/bin/find /scratch -xdev -name "core" -path \(/scratch/TEMP -o /scratch/TEMP1\) -prune -o -print
find: bad option /scratch/TEMP1)
Thanks,
f. halili
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 06:41 AM
02-02-2009 06:41 AM
Re: find but ignore one or two directories.
You suggeestion works but it will still go through the directories I want to ignore.
I want to skip some directories as they are huge, so don't want to go through them.
Thanks,
f. halili
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 06:49 AM
02-02-2009 06:49 AM
Re: find but ignore one or two directories.
then check the 'find' option '-prune':
-prune: If the current entry is a directory, cause find to skip that directory.
or better:
find . ! -path ./
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 07:08 AM
02-02-2009 07:08 AM
Re: find but ignore one or two directories.
-prune avoids from search in any sub-directory.
-path works without the '!':
find . -name core -path
V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 07:15 AM
02-02-2009 07:15 AM
Re: find but ignore one or two directories.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 07:15 AM
02-02-2009 07:15 AM
Re: find but ignore one or two directories.
find /usr -xdev -name "core" -path /usr/local -o -print -path /usr/etc -prune -o -print
Sagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 07:25 AM
02-02-2009 07:25 AM
Re: find but ignore one or two directories.
find . ! -path ./
'!' semms to not work with option '-name'
V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 07:36 AM
02-02-2009 07:36 AM
SolutionPlease have a look at the belows, This might be helpful.
i have the fstab file at the following locations on my system.
# find / -name fstab
/etc/fstab
/usr/newconfig/etc/fstab
/var/sujit/etc/fstab
/var/sujit/etc/etc/fstab
# find / \( ! -path "/etc/*" \) -name fstab
/usr/newconfig/etc/fstab
/var/sujit/etc/fstab
/var/sujit/etc/etc/fstab
# find / \( ! -path "/etc/*" \) -a \( ! -path "/var/*" \) -name fstab
/usr/newconfig/etc/fstab
# find / \( ! -path "/etc/*" \) -a \( ! -path "/usr/*" \) -name fstab
/var/sujit/etc/fstab
/var/sujit/etc/etc/fstab
# find / -name fstab
/etc/fstab
/usr/newconfig/etc/fstab
/var/sujit/etc/fstab
/var/sujit/etc/etc/fstab
Hope this is helpful.
Regards
Sujit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 08:58 AM
02-02-2009 08:58 AM
Re: find but ignore one or two directories.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2009 08:26 PM
02-02-2009 08:26 PM
Re: find but ignore one or two directories.
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1303248
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1276654