Categories
Server

Unix: Count number of files in a folder

You have run out of inodes on your server and you have no idea where all those files are?

The following command will tell you the number of files of each directory so you can spot where the hell they are.

for i in /home/*; do echo $i; find $i | wc -l; done

When you see a directory with lots files, you can continue examining its subdirectories by calling again the command on it.

for i in /home/thisone/*; do echo $i; find $i | wc -l; done