I have a fairly large directory tree whose contents I am not familiar with, and I have reason to believe that there are some enormously large directories buried in there somewhere. How do I find where they are?
Context: I am cleaning up a web application that has left behind a lot of files over the years. I already found and cleared a directory that contained hundreds of thousands of tiny ancient "session.*" files, but
find commands over the hierarchy are still extremely slow.
The tree is large enough that
ls -RC | less is not an attractive solution. If I was looking for a directory taking up a lot of disk space, I would divide and conquer using
du -s *. How can I find the directories that contain the largest number of files?
Edit: This is on an old server, so I cannot use
du --inodes to count the files. For most readers that's probably the best solution.