Command to get Inodes usage without having to create temporary files first

551 Views Asked by At

I used to use this command and it needs to create temporary file first, so it doesn’t work when inodes is full and will throw an error: cannot create temporary file in '/tmp': Disk quota exceeded

find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn

But when I use the other command below, it could sort the inodes usage without creating temporary file first, why is that?

echo "Detailed Inodes usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf "$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n"

The latter will not sort the inodes usage so it will take a while to check which folder used most inodes. But the former command sorted the result.

I need a command to sort Inodes usage without having to create temporary files first, so it could work when inodes usage is full.

Your help is really appreciated!

0

There are 0 best solutions below