Last active
March 23, 2020 01:17
-
-
Save maxrp/8b201219ba87b468edf9174eee65dadf to your computer and use it in GitHub Desktop.
ultra basic posix covid stat tracking
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 | |
URL="https://covidtracking.com/api/us.csv" | |
get(){ | |
curl -s "${URL}" | |
} | |
print_stats(){ | |
awk -F, '/^[1-9]/{ | |
test_hit_rate=100*($1/$3); | |
hospitalization_rate=100*($4/$1); | |
death_rate=100*($5/$1); | |
printf(" - %'"'"'d", $3); | |
print " patients tested."; | |
printf(" - %.2f", test_hit_rate); | |
print "% tested are infected." ; | |
printf(" - %.2f", hospitalization_rate); | |
print "% are hospitalized."; | |
printf(" - %.2f", death_rate); | |
print "% have died." | |
}' | |
} | |
main(){ | |
while true; do | |
echo -n "* " | |
date | |
get | print_stats | |
sleep 3600 | |
echo | |
done | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment