Count inodes in a directory

December 26, 2019 Stanly G Linux, Files 0 minutes, 32 seconds

When you have over 10,000 files in a single directory, Linux gets wonky. When you have 1,000,000, it becomes impossible.

Finding where those files are hiding can also be tricky.

This can also exhibit symptoms with backups taking forever, or PHP being grouchy.

cd /suspected-path/
for D in $(find . -type d) ; do echo -n "$D:" ;  find $D -type f | wc -l ; done | sort -t: -k2 -n

You probably want to run this in a screen session, and/or with tee so that you can capture the output as it runs. This can take hours depending on how many files are in a path.