I am using Geektool to run the below shell script which, as written, uses curl to get an XML file containing weather information for the defined location and then echoes the current temperature followed by current conditions.
I am relatively experienced in PHP and HTML so I can kind of read the code to see what's happening where, but otherwise I am new to shell as of an hour ago. I've spent the last few hours googling to figure out how to do what I want to do to no avail. As written, the script echoes the temperature followed by conditions, so it'll output something like "77 Mostly Cloudy."
However, I want it to output "Mostly Cloudy, 77 °F" but I cannot for the life of me figure out how to swap around the order and add the °F to the mix without throwing a syntax error.
Any help would be GREATLY appreciated -- I'm sure this is a SUPER simple adjustment to someone experienced in shell.
Code:
#!/bin/sh
Location="33004"
Unit="i"
XML="$(curl -s "http://wxdata.weather.com/wxdata/weather/local/$Location?cc=*&unit=$Unit&dayf=0")"
echo "$XML" | xpath 'weather/cc/t | weather/cc/tmp' 2>&1 |grep -E "<t>|<tmp>" |sed -e 's/-- NODE --//' | sed -e 's/<[^>]*>//g' | tr '\n' ' '
printf "\n"
I am relatively experienced in PHP and HTML so I can kind of read the code to see what's happening where, but otherwise I am new to shell as of an hour ago. I've spent the last few hours googling to figure out how to do what I want to do to no avail. As written, the script echoes the temperature followed by conditions, so it'll output something like "77 Mostly Cloudy."
However, I want it to output "Mostly Cloudy, 77 °F" but I cannot for the life of me figure out how to swap around the order and add the °F to the mix without throwing a syntax error.
Any help would be GREATLY appreciated -- I'm sure this is a SUPER simple adjustment to someone experienced in shell.