Skip to content

Instantly share code, notes, and snippets.

@0x48piraj
Created September 25, 2021 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0x48piraj/f45f8125e55ff2a389a9e6fa3311ad3f to your computer and use it in GitHub Desktop.
Save 0x48piraj/f45f8125e55ff2a389a9e6fa3311ad3f to your computer and use it in GitHub Desktop.
CLOC: Count the lines of code of any project recursively grouped by file extensions
find ./ -not -path "./.git/*" -type f -exec wc -l {} + |
awk '{print tolower($0)}' |
sed -e '$ d' |
sed -e "s#/.*/##g" |
sed -e "s/\./ \./g" |
awk '
{ if ( NF <= 2 ) { count["none"] += $1 } else { count[$NF] += $1 } }
{ next }
END { for (group in count) printf("%d%s%s\n", count[group], OFS, group) }
' |
sort -n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment