dotfiles

personal dotfiles
git clone git://git.benoneill.xyz/dotfiles
Log | Files | Refs | README | LICENSE

commit 5617e0e9afe11bf548b15eb89a4420ed1b0b7331
parent 4f393740868c23b4c4055cdef2b5701a9c24ac00
Author: Ben O'Neill <ben@benoneill.xyz>
Date:   Sat, 21 Mar 2020 16:09:17 -0400

Allow listing countries and catching when no data found

Diffstat:
M.local/bin/corona | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/.local/bin/corona b/.local/bin/corona @@ -1,9 +1,10 @@ #!/bin/sh -# See COVID-19 statistics for the world, a country, or state/territory. +# See COVID-19 statistics for the world, a country, or state/territory [ -z $1 ] && country="World" || country="$1" [ -z $2 ] || state="$2" + ([ ! -f ~/.local/share/corona ] || [ "$(stat -c "%y" ~/.local/share/corona 2>/dev/null | cut -d ' ' -f1)" != "$(date '+%Y-%m-%d')" ]) && curl -s https://corona-stats.online > ~/.local/share/corona @@ -14,10 +15,13 @@ [ -z $state ] && grep_query="$country" || grep_query="$state" +[ $country = "ls" ] && sed -r 's/║//g;s/\s*//g;s/│/|/g;s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g' ~/.local/share/corona | awk -F '|' '{print $2}' | sed '/^\s*$/d;s/\*//' | sort | uniq && exit + stats="$(grep "$grep_query" $file | sed -r 's/║//g;s/\s*//g;s/│/|/g;s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g')" total="$(echo $stats | awk -F '|' '{print $3}')" +[ -z $total ] && echo "No data found for this country!" 3>&1 1>&2 2>&3 3>&1 && exit -1 recovered="$(echo $stats | awk -F '|' '{print $4}')" deaths="$(echo $stats | awk -F '|' '{print $5}')" active="$(echo $stats | awk -F '|' '{print $6}')"