Skip to content

Instantly share code, notes, and snippets.

@yshalsager
Created November 6, 2018 19:07
Show Gist options
  • Save yshalsager/f0da4f541ad6289f6c55ffde9b279340 to your computer and use it in GitHub Desktop.
Save yshalsager/f0da4f541ad6289f6c55ffde9b279340 to your computer and use it in GitHub Desktop.
This script counts the total releases downloads from all repositories in a certain organization
curl -s https://api.github.com/orgs/$1/repos | egrep '"name"' | cut -d '"' -f4 > repos
cat repos | while read repo; do
curl -s https://api.github.com/repos/$1/$repo/releases | egrep 'download_count' | cut '-d:' -f 2 | sed 's/,/+/' | xargs echo | xargs -I N echo N 0 | bc >> counts
done
cat counts | while read repo; do
perl -nle '$sum += $_ } END { print $sum'
done
rm repos counts 2> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment