top of page
  • Writer's pictureTroy Web Consulting

Recursively Count File Types and Files in a Directory

I was tired of writing this every time I needed to so I'm blogging. Copy/paste this onto a command line and it will print the name of the file extension and the number of files that have that file extension.

for f in `find . -type f | awk -F/ '{ print $NF; }' | awk -F. '{ print $NF; }' | sort -u` ; do echo -n $f:; find . -type f -iname "*$" | wc -l; done


bottom of page