Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Corona Stats
#1
Here is a script you can use to check on the progress of the COVID-19 virus. I saw a video on it by Luke Smith about a week ago and I've taken his script and modified it. It uses curl to download the data from John Hopkins University and displays the data for the US and the world. The downloaded chart is world-wide so you could add lines to include data from any country of interest.

The display is a bit wide, so I suggest maximizing your terminal window. Depending on the numbers, you may have to adjust the number of tabs in the awk commands to line up right. If you're not in the Eastern time zone you will need to change EDT to your timezone.

Code:
#!/bin/bash
# corona-stats

readonly TODAY=$(date '+%d %b %Y')
readonly NOW=$(date '+%H:%M')
readonly URL="https://corona-stats.online/?minimal=true"

# Download the data and remove color codes

curl -s "$URL" > /tmp/corona
sed -i 's/\x1b\[[0-9;]*m//g' /tmp/corona

# Extract and display pertinent data

clear
echo -e "\n\e[1;34mCorona (COVID-19) virus stats for $TODAY\e[0m"
echo -e "\n\e[1;33m\t\tTotal\t(New)\t\tDeaths\t(New)\tRecovered\tActive\tCritical\tCases per 1M pop\e[0m"
grep "USA" /tmp/corona | awk '{ print $2"\t\t"$4"\t("$5")\t"$7"\t("$8")\t"$10"\t\t"$11"\t"$12"\t\t"$13 }'
grep -m2 "World" /tmp/corona | tail -n1 | awk '{ print $1"\t\t"$2"\t("$3")\t"$5"\t("$6")\t"$8"\t\t"$9"\t"$10"\t\t"$11 }'
echo "Data downloaded at $NOW EDT"
echo $'\n'$"Stay safe. Stay inside. Wash your hands!"

exit
Rick Romig
"It's never wrong to introduce a child to Linux."
@ludditegeek
Rick's Tech Stuff
GitHub
Reply
#2
It works . Thanks. Though the results are rather depressing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)