-
Notifications
You must be signed in to change notification settings - Fork 0
/
corona.sh
executable file
·47 lines (36 loc) · 1.04 KB
/
corona.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# Inspired by https://www.youtube.com/watch?v=cQ03v4d3QEo
# Thanks to https://github.com/sagarkarira/coronavirus-tracker-cli for showing the curl commands they use.
# Rank │ World │ Total Cases │ New Cases ▲ │ Total Deaths │ New Deaths ▲ │ Recovered │ Active │ Critical │ Cases / 1M pop
CONTENT=$HOME/.corona-stats
update () {
[ "$(stat -c %y $CONTENT 2>/dev/null | awk -F'[;:]' '{print $1":"$2}')" != "$(date '+%Y-%m-%d %H:%M')" ] &&
curl -s -o $CONTENT https://corona-stats.online?source=2 > $CONTENT
}
get () {
update
grep $1 $CONTENT |
sed "s/\s*//g ; s/▲//g ; s/║//g ; s/│/;/g" |
awk -F';' '{print "🤒 " $3 " (" $4 " new) 💀 " $5 " (" $6 " new)"}'
}
help () {
cat << EOF
written by finnkauski
corona
full - shows full country table
search - greps country name and finds the stats (case sensative)
help - prints help
* - shows stats for UK
EOF
}
case $1 in
full)
update
cat $CONTENT;;
search)
get $2;;
help)
help;;
*)
get "UK";;
esac