- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to find directories in depth
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
04-16-2008 06:06 AM
04-16-2008 06:06 AM
How to find directories in depth
I am looking for the options of find command to find out the directories in depth. Some thing like 2 level or 3 level. This should display the dir names with permissions.
Could anyone can help on this.
Thanks
Sree
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2008 06:10 AM
04-16-2008 06:10 AM
Re: How to find directories in depth
find /startdir -type d -exec "ll -d" {} \;
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2008 07:00 AM
04-16-2008 07:00 AM
Re: How to find directories in depth
If you are looking to limit 'find's ouput or selection to a particular depth (number of nodes) then you need to look either at the GNU utilities or roll-your-own. With Perl, this is easy. Here's a quick script to do your bidding.
# cat ./finddir
#!/usr/bin/perl -l
use strict;
use warnings;
use File::Find;
my $maxdepth = 3;
my ( $dir, $mode, $n );
find(
sub {
if ( -d ( $dir = $File::Find::name ) ) {
$n = $dir =~ tr ,/,/,;
$mode = ( stat($dir) )[2];
printf( "%04o %-s\n", $mode & 07777, $dir ) if $n <= $maxdepth;
}
},
@ARGV
);
...adjust the value of '$maxdepth' to your taste. Run the script passing the directory or directories you want to examine, like:
# ./finddir /var
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2008 08:11 AM
04-16-2008 08:11 AM
Re: How to find directories in depth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2008 09:00 AM
04-16-2008 09:00 AM
Re: How to find directories in depth
Thanks for your quick reply. While running the scrips I am getting the below error.
./find_dir.pl[3]: use: not found
./find_dir.pl[4]: use: not found
./find_dir.pl[5]: use: not found
./find_dir.pl[6]: my: not found
./find_dir.pl[6]: syntax error at line 7 : `(' unexpected
I am not good in scripting so if you can help me to sort out this it will be highly appreciable