Sort directories by number of files contained

Here is a one-liner which sorts all the directories under ‘/’ by the number of files contained: find / -type d -exec sh -c ‘ls -a1 "$1" | wc -l’ \"{}\" {} \; -print | \ sed  ‘$!N;s/\n/ /’ | sort -gr I recently needed this on a linux server where the inode quota was exceeded.Continue reading “Sort directories by number of files contained”