Last active
June 25, 2016 21:40
-
-
Save StevenMaude/b2c1e38df623b3daec448df5a7680a98 to your computer and use it in GitHub Desktop.
Count up UK Government petition signatures, across countries and constituencies.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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