starting from the current directory, you can try
find . -type d | cut -d/ -f 2 | uniq -c
All directories are listed here, starting from the current one, separate each line with the β/β symbol, select the field number β2β (each line starts with β./β, so your first field will be β.β) And then displays only unique lines and counts how often this unique string appears (-c option).
You can also add "sort -g" at the end.
source share