GNU find があると仮定すると、GNU find にディレクトリを見つけさせ、残りは bash に任せます:
find . -type d -print0 | while read -d '' -r dir; do
    files=("$dir"/*)
    printf "%5d files in directory %s\n" "${#files[@]}" "$dir"
done
find . -type f | cut -d/ -f2 | sort | uniq -c
- find . -type fタイプ- fileのすべてのアイテムを検索するには 、現在のフォルダーとサブフォルダー内
- cut -d/ -f2特定のフォルダーを切り取る
- sortフォルダ名のリストをソートする
- uniq -c各フォルダ名がカウントされた回数を返す
これは、現在のディレクトリ レベルのディレクトリごとのファイル数を出力します:
du -a | cut -d/ -f2 | sort | uniq -c | sort -nr