top of page

Currently Hiring! Visit our Careers Page

Troy Web Consulting Logo

Recursively Count File Types and Files in a Directory

  • Writer: Troy Web Consulting
    Troy Web Consulting
  • Mar 24, 2012
  • 1 min read

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