Skip to content

Instantly share code, notes, and snippets.

@arnehormann
Created June 13, 2014 09:42
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 arnehormann/b66656d353379073b23c to your computer and use it in GitHub Desktop.
Save arnehormann/b66656d353379073b23c to your computer and use it in GitHub Desktop.
count LOC in .git folders per language
#!/bin/bash
set -e -u -o pipefail # -x
echo $'Project\tCommit\tBranch\tFiletype\tLines'
for dir in *.git; do
export GIT_DIR="$dir"
export PREFIX=$(git for-each-ref --count=1 --sort=committerdate --format=$'%(objectname)\t%(refname)')
export BRANCH=$(echo -e "${PREFIX}" | cut -d $'\t' -f 1)
##### from these filetypes #####
for filetype in java cs rb go py as php html htm css js json xml conf cnf; do
echo -n -e "${dir}\t${PREFIX}\t${filetype}\t"
git --no-pager grep -h "" "${BRANCH}" -- "*.${filetype}" | wc -l || true
done
done | egrep -v $'\t0$'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment