Skip to content

Instantly share code, notes, and snippets.

@maxrp
Last active March 23, 2020 01:17
Show Gist options
  • Save maxrp/8b201219ba87b468edf9174eee65dadf to your computer and use it in GitHub Desktop.
Save maxrp/8b201219ba87b468edf9174eee65dadf to your computer and use it in GitHub Desktop.
ultra basic posix covid stat tracking
#!/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