Skip to content

Instantly share code, notes, and snippets.

@bijanebrahimi
Last active December 18, 2015 13:08
Show Gist options
  • Save bijanebrahimi/5787282 to your computer and use it in GitHub Desktop.
Save bijanebrahimi/5787282 to your computer and use it in GitHub Desktop.
#!/bin/bash
TMP_FILE="/tmp/election"
wget -qO- http://election.farsnews.com/electioninfo.js | sed 's/var //' | sed 's/ = /=/' | sed "s/\[/\(/" | sed "s/\]/\)/" > $TMP_FILE
source "$TMP_FILE"
echo "last Update: "${categoryarray[${#categoryarray[@]}-1]}
echo "$lastTotal ($lastCounted, $lastFailed)"
echo "%"$(echo "scale = 4; ($lastRohani / $lastTotal) * 100" | bc 2>/dev/null)" Rohani with $lastRohani votes"
echo "%"$(echo "scale = 4; ($lastQalibaf / $lastTotal) * 100" | bc 2>/dev/null)" Qalibaf with $lastQalibaf votes"
echo "%"$(echo "scale = 4; ($lastJalili / $lastTotal) * 100" | bc 2>/dev/null)" Jalili with $lastJalili votes"
echo "%"$(echo "scale = 4; ($lastRezaei / $lastTotal) * 100" | bc 2>/dev/null)" Rezaee with $lastRezaei votes"
echo "%"$(echo "scale = 4; ($lastVelayati / $lastTotal) * 100" | bc 2>/dev/null)" Velayati with $lastVelayati votes"
echo "%"$(echo "scale = 4; ($lastQarazi / $lastTotal) * 100" | bc 2>/dev/null)" Qarazi with $lastQarazi votes"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment