Skip to content

Instantly share code, notes, and snippets.

@treyharris
Last active May 27, 2019 23:23
Show Gist options
  • Select an option

  • Save treyharris/7a761db60e91323aa72868445fb6908c to your computer and use it in GitHub Desktop.

Select an option

Save treyharris/7a761db60e91323aa72868445fb6908c to your computer and use it in GitHub Desktop.
#!/bin/zsh
# Count the filename extensions in the current or named subtree
# Can be used as an autoloaded function or as a script.
local rootdir usage
rootdir="${PWD}"
usage="usage: $0 [DIR]"
if (( $#argv == 1 )) ; then
rootdir="${argv[1]}"
elif (( $#argv )) ; then
echo "${usage}" 1>&2
return 1
fi
print -l "${rootdir}"/**/*(.on:e) |
uniq -c |
sort -nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment