You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

weather 730B

123456789101112131415161718
  1. #!/bin/sh
  2. #
  3. # z3bra - (c) wtfpl 2014
  4. # fetch weather and temperature using openweathermap API
  5. CITY=${1:-atwater}
  6. FORECAST=${FORECAST:-5}
  7. UNITS=${UNITS:-imperial}
  8. URL="http://api.openweathermap.org/data/2.5/forecast/daily/?q=$CITY&cnt=$FORECAST&mode=xml&units=$UNITS"
  9. curl -s "$URL" | sed -e 's/.*time day="\([^" ]*\).*/\1,/p' \
  10. -e 's/^.*symbol.*name="\([^"]*\).*$/\1,/p' \
  11. -e 's/^.*temperature.*day="\([^"]*\).*$/\1°F/p'\
  12. -e 'd' \
  13. | paste -d "" - - - \
  14. | sed 's/^\(.*\),\(.*\),\(.*\)/\1,\3,\2/' \
  15. | column -t -s, -o" - "