find . -mindepth 1 -type d -print0 | while IFS= read -r -d '' i ; do echo -n $i": " ; ls -p "$i" | grep -v / | wc -l ; done
示例(格式为易读性):
pwd/mnt/Vancouver/Programming/scripts/claws/corpus
ls -ltotal 8drwxr-xr-x 2 victoria victoria 4096 Mar 28 15:02 'Catabolism - Autophagy; Phagosomes; Mitophagy'drwxr-xr-x 3 victoria victoria 4096 Mar 29 16:04 'Catabolism - Lysosomes'
ls 'Catabolism - Autophagy; Phagosomes; Mitophagy'/ | wc -l138
## 2 dir (one with 28 files; other with 1 file):ls 'Catabolism - Lysosomes'/ | wc -l29
使用tree可以更好地可视化目录结构:
tree -L 3 -F ..├── Catabolism - Autophagy; Phagosomes; Mitophagy/│ ├── 1│ ├── 10│ ├── [ ... SNIP! (138 files, total) ... ]│ ├── 98│ └── 99└── Catabolism - Lysosomes/├── 1├── 10├── [ ... SNIP! (28 files, total) ... ]├── 8├── 9└── aaa/└── bbb
3 directories, 167 files
man find | grep mindep-mindepth levelsDo not apply any tests or actions at levels less than levels(a non-negative integer). -mindepth 1 means process all filesexcept the starting-points.