From e75bab87fc1638f5593b19c52a8f73ddcfdefdf2 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Mon, 30 Nov 2020 18:08:22 +0530 Subject: added a script that gets weather info every hour --- scripts/weather | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 scripts/weather (limited to 'scripts/weather') diff --git a/scripts/weather b/scripts/weather new file mode 100755 index 00000000..3fcab925 --- /dev/null +++ b/scripts/weather @@ -0,0 +1,12 @@ +#!/bin/bash + +get_current_temp() { + temp=$(curl wttr.in | grep °C | awk 'NR==1 {print $9 "°C"}' | sed -r "s/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g") # > /tmp/weather_temperature) + stat=$(curl wttr.in | awk 'NR==3 {print $1}') + echo $temp "("$stat")" +} + +while :; do + echo $(get_current_temp) > /tmp/weather_stat + sleep 3600 +done -- cgit v1.2.3