February 15, 2009

Count files in subdirectories

find . -type f -print | awk '{ FS="/"; print $2; }' | uniq -c | sort -n

There’s not an easy way (as far as I know) to get a summary of how many files are in each subdirectory of a given parent directory, so I came up with this one-liner.