Created
October 18, 2016 17:26
-
-
Save cbuelo/57000e81e98a6bf648db0f431ef53a66 to your computer and use it in GitHub Desktop.
bash file to download surface station weather data from NOAA's National Climatic Data Center
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 | |
# Script to download weather data | |
STATION='726228-99999' | |
STARTYEAR=1973 | |
ENDYEAR=2005 | |
USER='ftp' | |
PASSWD='[email protected]' | |
HOST='ftp.ncdc.noaa.gov' | |
YEAR=($(seq $STARTYEAR $ENDYEAR)) | |
DOWNDIR="/home/cal/Documents/GradSchool/Classes/Fall2016/EnvirClim/Project/WeatherData/GZ" | |
echo $YEAR | |
for i in "${YEAR[@]}"; do | |
CURYEAR=$i | |
CURFILE=$STATION"-"$CURYEAR".gz" | |
echo $CURFILE | |
ftp -in $HOST <<-SCRIPTEND | |
user $USER $PASSWD | |
passive | |
lcd $DOWNDIR | |
cd /pub/data/noaa | |
cd $CURYEAR | |
get $CURFILE | |
quit | |
SCRIPTEND | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment