From 4c5cd4a9e35484476525538e5a7c303e038f69f8 Mon Sep 17 00:00:00 2001 From: Hugo Licon Date: Tue, 4 Aug 2020 19:50:02 -0600 Subject: [PATCH] replace awk by cut --- scripts/weather.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/weather.sh b/scripts/weather.sh index 95274fb..b5bf371 100755 --- a/scripts/weather.sh +++ b/scripts/weather.sh @@ -27,8 +27,8 @@ display_weather() fi weather_information=$(fetch_weather_information $display_weather) - weather_condition=$(echo $weather_information | awk '{print $1;}') # Sunny, Snow, etc - temperature=$(echo $weather_information | awk '{print $2;}') # +31°C, -3°F, etc + weather_condition=$(echo $weather_information | cut -d "+" -f 1 | cut -d "-" -f 1) # Sunny, Snow, etc + temperature=$(echo $weather_information | cut -d '+' -f 2) # +31°C, -3°F, etc unicode=$(forecast_unicode $weather_condition) echo "$unicode ${temperature/+/}" # remove the plus sign to the temperature @@ -36,13 +36,13 @@ display_weather() forecast_unicode() { - weather_condition=$1 + weather_condition=$(echo $weather_condition | awk '{print tolower($0)}') - if [[ $weather_condition =~ 'Snow' ]]; then + if [[ $weather_condition =~ 'snow' ]]; then echo '❄ ' - elif [[ (($weather_condition =~ 'Rain') || ($weather_condition =~ 'Shower')) ]]; then + elif [[ (($weather_condition =~ 'rain') || ($weather_condition =~ 'shower')) ]]; then echo '☂ ' - elif [[ (($weather_condition =~ 'Overcast') || ($weather_condition =~ 'Cloud')) ]]; then + elif [[ (($weather_condition =~ 'overcast') || ($weather_condition =~ 'cloud')) ]]; then echo '☁ ' elif [[ $weather_condition = 'NA' ]]; then echo ''