Skip to content

Instantly share code, notes, and snippets.

@cbuelo
Created October 18, 2016 17:26
Show Gist options
  • Save cbuelo/57000e81e98a6bf648db0f431ef53a66 to your computer and use it in GitHub Desktop.
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
#!/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