Skip to content

Instantly share code, notes, and snippets.

@alexey-m-ukolov
Last active October 29, 2015 04:24
Show Gist options
  • Save alexey-m-ukolov/8194a7a7f4c131292266 to your computer and use it in GitHub Desktop.
Save alexey-m-ukolov/8194a7a7f4c131292266 to your computer and use it in GitHub Desktop.
Get all extensions and their respective file count in a directory
#SOURCE
http://serverfault.com/questions/183431/get-all-extensions-and-their-respective-file-count-in-a-directory
sudo find ./ -type f | grep -E ".*\.[a-zA-Z0-9]*$" | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' | sort | uniq -c | sort -n
#EXPLANATION:
# find only file, not directory
find ./ -type f
# filter file with extension
grep -E ".*\.[a-zA-Z0-9]*$"
# delete path and file name, save only extension
sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/'
# sort, uniq and sort
sort | uniq -c | sort -n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment