Created
November 17, 2013 08:03
-
-
Save kumarsoumya/7510659 to your computer and use it in GitHub Desktop.
Please read the comments at the top.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This script prints the current temperature of a city(by zip code) by going to | |
# the weather channel homesite and filtering the div container called "current temp:" | |
# This is a modified script file from a course website. | |
# | |
ZIP=$1 | |
URL_WEATHER="http://www.weather.com/weather/today/"$ZIP | |
#echo $URL_WEATHER | |
curl $URL_WEATHER > temp.tmp 2> err | |
#cat temp.tmp | |
STR1="<div class=\"wx-temperature\">" | |
STR2="<span itemprop=\"temperature-fahrenheit\">" | |
#echo $STR1 | |
#echo `cat temp.tmp' | |
`cat temp.tmp | grep "$STR1" > temp2.tmp` | |
`cat temp2.tmp | grep "$STR2" > temp3.tmp` | |
`sed "s/<[^0-9]*>//" temp3.tmp > 1.tmp` | |
`sed "s/<.*//" 1.tmp > 2.tmp` | |
TEMP=`head -1 2.tmp` | |
rm -f 1.tmp | |
rm -f 2.tmp | |
rm -f temp.tmp | |
echo "The current temperature is "$TEMP"F" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment