Skip to content

Instantly share code, notes, and snippets.

@bendmorris
Created December 27, 2014 20:49
Show Gist options
  • Save bendmorris/2f3013c32fd2c6baccf4 to your computer and use it in GitHub Desktop.
Save bendmorris/2f3013c32fd2c6baccf4 to your computer and use it in GitHub Desktop.
Count # of files and total lines by file type, in all git repos starting from the current directory
#!/bin/bash
DIR=$(pwd)
REPOS=$(find . -type d -name .git)
echo "-- Directory: " $DIR
echo "-- Repos: " $REPOS
for i in hx py xml; do
echo $i
FILES=$(for j in $REPOS; do cd "$DIR/$j/../"; git ls-files --full-name | grep "\.$i" | while read line; do echo "$DIR/$j/../$line"; done; done)
echo " files:" "$(echo $FILES | wc -w)"
echo " lines:" "$(for j in $FILES; do cat $j; done | wc -l)"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment