I have a large number of directories, and I want to count with bash commands the number of directories in each of these directories. I am having a hard time piping ls
and wc
to achieve what I want.
E.g., if I have the following folder structure (where the leaf folders might contain further subfolders):
.
├── folder1
│ └── subfoldera
├── folder2
│ ├── subfoldera
│ └── subfolderb
├── folder3
│ ├── subfoldera
│ ├── subfolderb
│ └── subfolderc
└── folder4
├── subfoldera
├── subfolderb
└── subfolderc
Then I wish to have the counts
1
2
3
3
and so on.
ls
? – Cyrus Aug 17 '20 at 20:48