bic ton
bic ton

Reputation: 1408

How to loop through years with months and points?

I want to loop throgh years and months and insert them in the wget command:

for f in [from 1983.07 to 2017.06]; do wget https://www.ncei.noaa.gov/thredds/fileServer/cdr/isccp_hgm_agg/files/isccp-basic/hgm/ISCCP-Basic.HGM.v01r00.GLOBAL.$f.99.9999.GPC.10KM.CS00.EA1.00.nc;done

Upvotes: 0

Views: 70

Answers (1)

Barmar
Barmar

Reputation: 782066

Assuming you're using bash, you can use .. to generate a sequence of numbers.

It won't leave leading zeroes in numbers, so you need to handle the 1-digit and 2-digit months separately.

For the ranges that include full years, you can combine a year

for f in 1983.0{7..9} {1984..2016}.0{1..9} {1983..2016}.{10..12} 2017.0{1..6}; do
    wget "https://www.ncei.noaa.gov/thredds/fileServer/cdr/isccp_hgm_agg/files/isccp-basic/hgm/ISCCP-Basic.HGM.v01r00.GLOBAL.$f.99.9999.GPC.10KM.CS00.EA1.00.nc"
done

Upvotes: 1

Related Questions