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

13 lines
403 B
Bash
Raw Normal View History

2017-06-26 23:56:37 +02:00
#!/bin/sh
# Author: Alexander Epstein https://github.com/alexanderepstein
country=$(curl -s ipinfo.io/country) > /dev/null
if [ $country = "US" ];then
city=$(curl -s ipinfo.io/city) > /dev/null
region=$(curl -s ipinfo.io/region) > /dev/null
region=$(echo "$region" | tr -dc '[:upper:]')
curl wttr.in/$city,$region
else
location=$(curl -s ipinfo.io/loc) > /dev/null
curl wttr.in/$location
fi