NickTheGreek 160 Report post Posted November 10, 2016 http://stackoverflow.com/questions/15216370/how-to-count-number-of-files-in-each-directory find . -type d -print0 | while read -d '' -r dir; do files=("$dir"/*) printf "%5d files in directory %s\n" "${#files[@]}" "$dir" done findfiles() { echo "$1" $(find "$1" -maxdepth 1 -type f | wc -l) } export -f findfiles find ./ -type d -exec bash -c 'findfiles "$0"' {} \; 2 Quote Share this post Link to post Share on other sites
NickTheGreek 160 Report post Posted October 8, 2018 find . -maxdepth 1 -type d -print0 | while read -d '' -r dir; do num=$(find $dir -ls | wc -l); printf "%5d files in directory %s\n" "$num" "$dir"; done Quote Share this post Link to post Share on other sites
NickTheGreek 160 Report post Posted October 10, 2018 du -a | cut -d/ -f2 | sort | uniq -c | sort -nr Quote Share this post Link to post Share on other sites