2
0
Fork 0
mirror of https://github.com/alexanderepstein/Bash-Snippets synced 2018-11-08 02:59:35 +01:00

Fixing weather grabbing initials for states with two words

This commit is contained in:
Alex Epstein 2017-11-25 12:29:31 -05:00
parent aec1a885ae
commit 98c6210d06

View file

@ -40,7 +40,11 @@ getIPWeather()
if [[ $country == "US" ]]; then ## if were in the us id rather not use longitude and latitude so the output is nicer if [[ $country == "US" ]]; then ## if were in the us id rather not use longitude and latitude so the output is nicer
city=$(httpGet ipinfo.io/city) > /dev/null city=$(httpGet ipinfo.io/city) > /dev/null
region=$(httpGet ipinfo.io/region) > /dev/null region=$(httpGet ipinfo.io/region) > /dev/null
if [[ $(echo $region | wc -w) == 2 ]];then
region=$(echo $region | grep -Eo "[A-Z]*" | tr -d "[:space:]")
else
region=$(echo "$region" | cut -c "1-2" | tr "[:lower:]" "[:upper:]") region=$(echo "$region" | cut -c "1-2" | tr "[:lower:]" "[:upper:]")
fi
httpGet $locale.wttr.in/$city,$region$1 httpGet $locale.wttr.in/$city,$region$1
else ## otherwise we are going to use longitude and latitude else ## otherwise we are going to use longitude and latitude
location=$(httpGet ipinfo.io/loc) > /dev/null location=$(httpGet ipinfo.io/loc) > /dev/null