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

Categories
Server

Unix: Remove tons of files

You may not be able to delete lot of files with the command “rm”.
The error could be “Argument list too long”.

One possible solution is to use the “find” command and the “-delete” option.

The following command is deleting all files in the /deleteme directory.
It deletes also all files in subdirectories but leaves subdirectories structure intact.

find /deleteme -type f -print -delete