As title, I need to look into a particular directory and list the number of files per level. The directory is pretty large, about 10-15 levels deep. For instance, if I have the following:D1||-- D2A (5 files in this directory)|    |-- D3A (6 files in this directory)|    |-- D3B (7 Files in this directory)||-- D2B (1 file in this directory)Then it should tell me that level 3 has 13 files and level 2 has 6 files (or 6+13, doesn't matter). Can Tree accomplish this? I've tried around mixing the options but it does not seem to work.
Can tree be used to list the number of files per level?
directory;directory structure;tree
find . -type d | \perl -ne 'BEGIN{ sub cnt{ $file=shift; $c=find $file -maxdepth 1 -type f | wc -l;int(`$c`) }} chomp; printf %s %s\n, $_, cnt($_)' | \perl -ne '/^(.*) (\d*)$/; $_{scalar(split /\//, $1)}+=$2; END { printf Depth %d has %d files.\n, @$_ for map { [$_,$_{$_}] } sort keys %_ }'Results:Depth 1 has 7 files.Depth 2 has 2353 files.Depth 3 has 2558 files.Depth 4 has 8242 files.Depth 5 has 6452 files.Depth 6 has 674 files.Depth 7 has 1112 files.Depth 8 has 64 files.Depth 9 has 154 files.