I needed to get the number of files in a directory and recurse through all subdirectories doing the same. I nedded it so i could compare two sets of directory trees for something I was working on.
My Irish chum
Enstyne came up with this Perl solution which seems to do the trick nicely!
perl -e 'sub z{my(@l)=glob(($p=$_[0])."/*");my(@x,$c);foreach $f(@l){$c++;push(@x,$f) if -d $f} print"$p: $c\n";foreach $f (@x){z($f)}}z(".");'
NSUL2:~# perl -e 'sub z{my(@l)=glob(($p=$_[0])."/*");my(@x,$c);foreach $f(@l){$c++;push(@x,$f) if -d $f} print"$p: $c\n";foreach $f (@x){z($f)}}z(".");'
.: 5
./dan: 4
./Mail:
./Public: 5
./Public/Apps: 3