Here’s a bash script I wrote to get the weather for Boston (the weather-util command recently broke for Boston, MA):
#!/bin/bash
# Shows the weather forecast for Boston, MA
TMPFILE=${TMPDIR-/tmp}/ne_weather.$$
curl -s 'http://weather.noaa.gov/pub/data/forecasts/state/ma/maz007.txt' > $TMPFILE
sed -n '/^TAB/,+11p' < $TMPFILE
sed -n '/BOSTON/,+3p' < $TMPFILE
rm $TMPFILE
I am using a temp file because I can’t figure out how to use sed on the output of curl in one pass. Any suggestions for doing this without resorting to a temporary file? Or is it perfectly OK?
You can pipe the output of
curlintosed: