- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Help Needed on Find
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
Discussions
Discussions
Forums
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
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
тАО06-17-2007 09:19 AM
тАО06-17-2007 09:19 AM
Help Needed on Find
I am searching a string using
find /interfaces/eu3/hmsl/italy/it10archive -xdev -exec grep -l 'string' {} \;.
I want to restrict the search only to that particular dir but find command finds the string in /interfaces/eu3/hmsl dir as well.
Is there any alternative to restrict the search for particular dir.
Thanks in advance.
Ta
Yogesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2007 09:59 AM
тАО06-17-2007 09:59 AM
Re: Help Needed on Find
> Is there any alternative to restrict the search for particular dir.
If you mean not to recursively descend within the starting directory, then:
# cd /desired_path
# find . -type f ! -path "./*/*" -exec grep -l 'string' {} \;
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2007 07:38 PM
тАО06-17-2007 07:38 PM
Re: Help Needed on Find
find /interfaces/eu3/hmsl/italy/it10archive -xdev -prune -exec grep -l 'string' {} \;
-prune should be your fried in this
HTH,
Art
- Tags:
- -prune
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-18-2007 12:20 AM
тАО06-18-2007 12:20 AM
Re: Help Needed on Find
>I want to restrict the search only to that particular dir but find command finds the string in /interfaces/eu3/hmsl dir as well.
I'm not sure how it finds in hmsl, when that directory is the grandparent of the starting directory?
Also you should change "{} \;" to "{} +".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-18-2007 12:54 AM
тАО06-18-2007 12:54 AM
Re: Help Needed on Find
Upon rereading, I noticed that you say that the "...find command finds the string in /interfaces/eu3/hmsl dir as well."
Including the '-type f' as I suggested should eliminate finding symbolic links if that is indeed a problem.
Too, if you do not want to chase symbolic links, add "! -follow" to your 'find' expressions.
Adding '-xdev' is extremely important if/when you do not want to cross mountpoints; most notably if/when you are searching the root ('/') directory.
Regards!
...JRF...