Skip to content

Instantly share code, notes, and snippets.

@AlexanderWingard
Last active October 8, 2020 12:31
Show Gist options
  • Save AlexanderWingard/4336d092b3966074410dbc0e29eb7132 to your computer and use it in GitHub Desktop.
Save AlexanderWingard/4336d092b3966074410dbc0e29eb7132 to your computer and use it in GitHub Desktop.
Character count csv of folder in git
#!/bin/bash
for commit in $(git rev-list --reverse --topo-order HEAD -- .)
do
sum=0
for file in $(git ls-tree -r --name-only $commit)
do
if [[ $(git show $commit:./$file | file -ib -) =~ "text/" ]]
then
count=$(git show $commit:./$file | tr -d '[:space:]' | wc -c)
sum=$((sum + count))
fi
done
meta=$(git log -n1 --format="format:%cI,%h,%an" $commit)
title=$(git log -n1 --format="format:%s" $commit | tr -d \")
echo "$sum,$meta,\"$title\""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment