nem.ec

Programming Information Security Recipes Personal Code Snippets

Display the top 20 directories in the current folder sorted by file count

Source: https://askubuntu.com/a/316194/80308

find . -maxdepth 1 -type d -print0 2>/dev/null | while IFS= read -r -d '' file; do 
    echo -e `ls -A "$file" 2>/dev/null | wc -l` "files in:\t $file"
done | sort -nr | head -n20 | awk '{print NR".", "\t", $0}'