File size: 950 Bytes
8be024f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
#!/bin/bash
buoy_number="42002"
curl_command="https://www.ndbc.noaa.gov/view_text_file.php?filename=42002hXXXX.txt.gz&dir=data/historical/stdmet/"
output_file="42002_XXXX.txt"
# get historical data
#for value in {1983..2022}
#do
#echo "${url//XXXX/"$value"}"
# curl ${curl_command//XXXX/"$value"} > ${output_file/XXXX/$value}
#done
#now get 2023 data
months=("junk" "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep")
month_curl="https://www.ndbc.noaa.gov/view_text_file.php?filename=42002X2023.txt.gz&dir=data/stdmet/YYY/"
month_output_file="42002_YYY.txt"
for i in {1..8}
do
temo_month_curl=${month_curl/X/"$i"}
#echo $temo_month_curl
temo_month_curl=${temo_month_curl/YYY/"${months[i]}"}
curl ${temo_month_curl} > ${month_output_file/YYY/"${months[i]}"}
done
# For some reason Sept URL is a totally different format
curl "https://www.ndbc.noaa.gov/data/stdmet/Sep/42002.txt" > "42002_Sep.txt"
echo "done"
|