The easiest way is to execute the command:
du -ks ./* | sort -n
or
find -type d -print0 | xargs -0 ls -ld | grep -v 4096
The complicated way is with bash script:
#!/bin/bash
# count inodes for each directory
LIST=`ls`
for i in $LIST; do
echo $i
find $i -printf "%i\n" | sort -u | wc -l
done
Another bash script for the same with more pleasant result display:
#!/bin/bash
# CVETOVE
ESC="\x1b["
RED=$ESC"31;01m"
GREEN=$ESC"32;01m"
YELLOW=$ESC"33;01m"
DBLUE=$ESC"34;01m"
MAGENTA=$ESC"35;01m"
BLUE=$ESC"36;01m"
WHITE=$ESC"37;01m"
GREY=$ESC"30;01m"
RESET=$ESC"39;49;00m"
if [ $# != 1 ]; then
echo -e "\n"
echo -e "Usage: $0 path_to_folder\n"
echo -e "Example: $0 /home/sentry/public_html/\n"
exit 1
fi
if [ ! -d $1 ]; then
echo "The argument must be a folder!"
exit 1
fi
echo -e "\n$WHITE[+$RESET Checking Inodes for folder: $GREY$1$RESET $WHITE+]$RESET \n"
for i in $( /usr/local/cpanel/bin/cpuwatch 10 ionice -c2 -n7 find $1 -maxdepth 1 -not -path "$1" -type d )
do
#echo "$(/usr/local/cpanel/bin/cpuwatch 5 ionice -c2 -n7 find $i | sort -u | wc -l) $i"
echo -e "$(/usr/local/cpanel/bin/cpuwatch 10 ionice -c2 -n7 find $i -printf "%i,\n" | sort -u | wc -l) $GREEN Inodes $RESET - $MAGENTA$i$RESET"
done | sort -n
echo -e "$WHITE==========================================================$RESET\n"