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.
How do I find where all the files are?
files;find
On an old distribution without du --inodes,find . -type d -ls | sort -n -k7,7will list all directories in order of increasing size, so you'll get the directories with the most files (or which contained the most files at some point) at the end of the list. The find command might well take a while to run but there's not much that can be done about that  even a divide-and-conquer du approach would have to read the same amount of information from the disk.