#!/bin/bash while getopts ":c:" opt do case ${opt} in c ) countries+=("${OPTARG}") ;; \? ) echo "Unknown option: -$OPTARG" >&2; exit 1;; : ) echo "Missing option argument for -$OPTARG" >&2; exit 1;; * ) echo "Unimplemented option: -$OPTARG" >&2; exit 1;; esac done shift $((OPTIND -1)) url="https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data/csse_covid_19_daily_reports" url_raw="https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports" if [ -z "${countries}" ] then echo "You need to specify country code. Exiting..." exit 1010 fi curl_get() { curl -s0 -k "${url_raw}/${e}.csv" 2>/dev/null | grep -vE "404: Not Found" > "${tmpfile}" } rulem () { if [ $# -eq 0 ]; then echo "Usage: rulem MESSAGE [RULE_CHARACTER]" return 1 fi printf -v _hr "%*s" $(tput cols) && echo -en ${_hr// /${2--}} && echo -e "\r\033[2C$1" } tmpfile="$(mktemp)" tmpfootnotes="$(mktemp)" e="$(date +'%m-%d-%Y')" curl_get if [ ! -s "${tmpfile}" ] then e="$(date -d'-1 days' +'%m-%d-%Y')" curl_get fi if [ ! -s "${tmpfile}" ] then echo "Unable to download CSV file. Exiting..." exit 1030 fi if [ ! -s "${tmpfile}" ] then echo "Unable to download CSV file. Exiting..." exit 1030 fi for ((i = 0; i < ${#countries[@]}; i++)) do c="${countries[$i]}" c="$(echo ${c} | sed 's/^ //g')" case ${c} in US) echo -e "* ${c} recovery rates are no longer tracked as of 2020-12-14" >> "${tmpfootnotes}" ;; esac country_field=$(awk -F, 'NR==1{for(i=1;i<=NF;i++)if($i~/Country.Region/)f[n++]=i}{for(i=0;i/dev/null