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

Posted on In QA

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?

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

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *