Skip to content

Instantly share code, notes, and snippets.

@StevenMaude
Last active June 25, 2016 21:40
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 StevenMaude/b2c1e38df623b3daec448df5a7680a98 to your computer and use it in GitHub Desktop.
Save StevenMaude/b2c1e38df623b3daec448df5a7680a98 to your computer and use it in GitHub Desktop.
Count up UK Government petition signatures, across countries and constituencies.
#!/bin/sh -e
if [ -z "$1" ]; then
echo "Usage: signature_count.sh <UK_GOVERNMENT_PETITION_JSON_URL>"
echo "e.g. signature_count.sh https://petition.parliament.uk/petitions/131215.json"
fi
DATA=$(wget -qO - "$1")
echo "Signatures by country:"
echo "$DATA" | jq .data.attributes.signatures_by_country[].signature_count | awk '{ sc += $1 } END { print sc }'
echo "Signatures by constituency:"
echo "$DATA" | jq .data.attributes.signatures_by_constituency[].signature_count | awk '{ sc += $1 } END { print sc }'
echo "Signature count:"
echo "$DATA" | jq .data.attributes.signature_count | awk '{ sc += $1 } END { print sc }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment