Skip to content

Instantly share code, notes, and snippets.

@bathtime
Created April 2, 2018 15:00
Show Gist options
  • Save bathtime/113bf195a5da50e475ee11fd6b91bf63 to your computer and use it in GitHub Desktop.
Save bathtime/113bf195a5da50e475ee11fd6b91bf63 to your computer and use it in GitHub Desktop.
Weather
#!/bin/sh
URL="https://weather.gc.ca/city/pages/on-77_metric_e.html"
A='center">'
B='</p>'
C='>'
D='&deg'
echo $(wget -q -O- "$URL" | awk -v v1="$A" -v v2="$B" -v v3="$C" -v v4="$D" '$0 ~ v1 ".*" v2 {sub(v2 ".*", ""); sub(".*" v1, ""); print $0; next;} $0 ~ v3 ".*" v4 {sub(v4 ".*", ""); sub(".*" v3, ""); print $0 "°C"; exit}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment