Last active
September 17, 2018 17:00
-
-
Save troyhill/b77898e267937f6896ec3e0e9cf52e99 to your computer and use it in GitHub Desktop.
R-bash integration: bash script
This file contains hidden or 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 downloads NOAA station data and saves it to a .csv file | |
# Usage: ./bash/getNOAAdata.sh ./bash/getNOAAdata.R 8656483 8665530 | |
if [ "$#" -lt 2 ]; then | |
echo "Usage: $0 R_script NOAA_station1 NOAA_station2 ..." 1>&2 | |
exit 1 | |
fi | |
Rscript=$1 | |
time_stamp=$(date +%Y%m%d) | |
dir_name="./RDATA/NOAAdata/${time_stamp}" | |
# make a date-stamped parent directory for the station data | |
if [ ! -d $dir_name ]; then | |
mkdir -p $dir_name | |
echo $dir_name | |
fi | |
# Pull data using the R script | |
shift | |
for i in "$@"; do | |
$Rscript $i $dir_name | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment