find directory with the most files

Written by Peter Davies on .

Had an odd issue of locating a client server issue where there was a problem large number of small files.

find . -type d | cut -d/ -f 2 | uniq -c

Resulting in:

user@server:/home/client/domains# find . -type d | cut -d/ -f 2 | uniq -c
      1 .
   2004 sub1.client.com
   3487 sub2.client.com
 249516 sub3.client.com

This showed that the last subdomain had a large number of files. It eventually transpired it was a lot of session files created by a PHP application.