Not sure if anyone cares, but I ran some speed tests on the code you guys helped me with:
#!/bin/sh
# Run: time ./testtime
A='center">'
B='</p>'
C='>'
D='°'
count=0
while [ $count -le 10000 ]; do
# mawk -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}' canada.html
# Var Run x bash input CPU
# awk 10000x mksh piped @ 55% 0m23.27s real 0m14.97s user 0m09.03s system
# awk 10000x mksh unpiped @ 51% 0m21.67s real 0m12.68s user 0m08.17s system
# nawk 10000x mksh unpiped @ 51$ 0m21.59s real 0m12.63s user 0m08.27s system
# gawk 10000x mksh unpiped @ 51% 0m21.64s real 0m12.55s user 0m08.40s system
# mawk 10000x bash unpiped @ 53% 0m07.83s real 0m04.54s user 0m02.81s system
# mawk 10000x mksh unpiped @ 51% 0m07.00s real 0m04.29s user 0m02.18s system
# mawk 10000x dash unpiped @ 52% 0m06.49s real 0m04.02s user 0m01.91s system
# mawk 10000x sh unpiped @ 52% 0m06.40s real 0m04.01s user 0m01.93s system
# mawk -vT1="$A" -vT2="$B" -vT3="$C" -vT4="$D" 'match ($0, T1 ".*" T2) {print substr ($0, RSTART+146, RLENGTH-150); next;} match ($0, T3 ".*" T4) {print substr ($0, RSTART+31, RLENGTH-35) "�C"; exit;}' canada.html
# Var Run x bash input CPU
# awk 10000x mksh piped @ 55% 0m21.14s real 0m12.78s user 0m09.29s system
# awk 10000x mksh unpiped @ 51% 0m19.70s real 0m10.71s user 0m08.22s system
# nawk 10000x mksh unpiped @ 51% 0m19.68s real 0m10.72s user 0m08.27s system
# gawk 10000x mksh unpiped @ 51% 0m19.68s real 0m10.81s user 0m08.15s system
# mawk 10000x bash unpiped @ 53% 0m07.70s real 0m04.59s user 0m02.71s system
# mawk 10000x mksh unpiped @ 51% 0m07.01s real 0m04.33s user 0m02.16s system
# mawk 10000x sh unpiped @ 52% 0m06.34s real 0m04.00s user 0m01.86s system
# mawk 10000x dash unpiped @ 52% 0m06.33s real 0m03.99s user 0m01.87s system
count=$((count+1))
done
beep
RudiC's code ran fastest in these tests with rdrtx1's code close behind. Mawk was fastest overall unpiped and run in sh/dash. I would have tested the other code but all other code did not work with this site. It also seems that these two implementations worked on every site I used them in!
Also, I had the output print to screen as I have not yet looked into redirecting it. The input was saved html script from a weather website; no net was used.
Amazing the difference it can make to switch a few things around.
One more thing. Here is a weather script that anyone can use, incase someone bumps into this on the net through a search:
#!/bin/sh
# Hamilton is used in this example. Replace with your own city's link.
URL="accuweather.com/en/ca/hamilton/l8l/weather-forecast/55490"
# Formulas:
# RSTART = +length of A
# RLENGTH = -length of (A + B)
A="txt : '"
B="',"
C="temp:'"
D="', realfeel:'"
# Use 'echo' as a hack to make both print outputs print on the same line
#echo $(wget -q -O- "$URL" | mawk -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;}')
echo $(wget -q -O- "$URL" | mawk -vT1="$A" -vT2="$B" -vT3="$C" -vT4="$D" 'match ($0, T1 ".*" T2) {print substr ($0, RSTART+7, RLENGTH-9); next;} match ($0, T3 ".*" T4) {print substr ($0, RSTART+6, RLENGTH-20) "�C"; exit;}')
Anyways, that's all. Thank you guys!