- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find command upto 2 sub-directory depth level
Operating System - HP-UX
1820137
Members
3235
Online
109619
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО10-31-2006 11:06 AM
тАО10-31-2006 11:06 AM
Hi,
What is the command syntax if i need to find the files and directories using find command upto the 2 sub-directory depth level from the specified search directory ?
Also how to include search for hidden files and sub-directories in the above command syntax ?
Thanks,
Shiv
What is the command syntax if i need to find the files and directories using find command upto the 2 sub-directory depth level from the specified search directory ?
Also how to include search for hidden files and sub-directories in the above command syntax ?
Thanks,
Shiv
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2006 11:27 AM
тАО10-31-2006 11:27 AM
Solution
Hi Shiv:
# find /mypath -xdev -print
...would find both files and directories recursively down every subdirectory. Hidden files (those with a leading ".") are also returned implicitly.
# find /mypath -xdev -type f -print
...would do the same as the first example, but return only files.
If you don't want to descend a particular subdirectory, you need to do something like:
# find /mypath -type f ! -path "/mypath/.shiv/*" -a ! -path "/mypath/.jrf/*"
...would find *files* (only) in the '/mypath' directory, but *skip* descending '/mypath/.shiv' and '/mypath/.jrf'.
Regards!
...JRF...
# find /mypath -xdev -print
...would find both files and directories recursively down every subdirectory. Hidden files (those with a leading ".") are also returned implicitly.
# find /mypath -xdev -type f -print
...would do the same as the first example, but return only files.
If you don't want to descend a particular subdirectory, you need to do something like:
# find /mypath -type f ! -path "/mypath/.shiv/*" -a ! -path "/mypath/.jrf/*"
...would find *files* (only) in the '/mypath' directory, but *skip* descending '/mypath/.shiv' and '/mypath/.jrf'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2006 01:00 PM
тАО10-31-2006 01:00 PM
Re: find command upto 2 sub-directory depth level
To descend upto the 2 sub-dir depth level starting from "/mydir" use:
# # find /mydir ! -path "/mydir/*/*/*"
...this will list hidden files and sub-dirs too.
~hope it helps
# # find /mydir ! -path "/mydir/*/*/*"
...this will list hidden files and sub-dirs too.
~hope it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2006 01:09 PM
тАО10-31-2006 01:09 PM
Re: find command upto 2 sub-directory depth level
Hi Shiv,
GNU find has the '-maxdepth' directive.
# find /path -maxdepth 2 -print
Without GNU find, you will have to grep on the number of slashes or directories in the path.
GNU find is available here:
http://hpux.cs.utah.edu/hppd/hpux/Gnu/findutils-4.2.28/
PCS
GNU find has the '-maxdepth' directive.
# find /path -maxdepth 2 -print
Without GNU find, you will have to grep on the number of slashes or directories in the path.
GNU find is available here:
http://hpux.cs.utah.edu/hppd/hpux/Gnu/findutils-4.2.28/
PCS
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP