How to find the number of files in each directories on Linux?

How to find the number of files in each sub-directories of a directory on Linux?

For example,

.
├── a19
├── a8
├── d2
├── ecfddd
└── t1

The number of sub-directories can be quite large. How to find the number of files in each sub-directories here?

asked Dec 21, 2014 by anonymous

1 Answer

 
Best answer

You can use this piece of script to find the number of files in sub directories:

for i in `ls -1`; do \
  echo $i; find $i -type f | wc -l; \
done
answered Dec 21, 2014 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...