At the risk of offering a shell-based answer (replace '.' with desired directory, add '-mindepth 1' to the find command to remove the current directory):
find . -type d | wc -l # Number of directories find . -type d | sort # Sorted listing of subdirectories
Another method, using perl (directories passed in via @ARGV):
#!/usr/bin/perl use strict; use vars qw(@directories); use warnings; use File::Find; foreach my $dir (@ARGV) { find(\&wanted, $dir); } print "Count of directories: ", scalar(@directories), "\n"; print "Directories:\n"; foreach my $dir (sort @directories) { print "\t", $dir, "\n"; } sub wanted { -d && push(@directories, $File::Find::name); }
In reply to Re: Finding total number of subdirectories and list them
by atcroft
in thread Finding total number of subdirectories and list them
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |