0

I'm trying to download data from the following link

export ICTP_DATASITE='http://clima-dods.ictp.it/data/Data/RegCM_Data/EIN15/1990/'

These are the codes :

for type in "air hgt rhum uwnd vwnd"
do
    for hh in "00 06 12 18"
    do
       curl -o ${type}.1990.${hh}.nc \
       ${ICTP_DATASITE}/EIN15/1990/${type}.1990.${hh}.nc
    done
done

But its not downloading and im getting the following error message

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: hgt
curl: (6) Could not resolve host: rhum
curl: (6) Could not resolve host: uwnd
curl: (6) Could not resolve host: vwnd.1990.00
curl: (7) Could not resolve host: vwnd.1990.00
curl: (7) Could not resolve host: vwnd.1990.00
curl: (6) Could not resolve host: 18.nc
curl: (3) <url> malformed
curl: (6) Could not resolve host: hgt
curl: (6) Could not resolve host: rhum
curl: (6) Could not resolve host: uwnd
curl: (6) Could not resolve host: vwnd.1990.00
curl: (7) Could not resolve host: vwnd.1990.00
curl: (7) Could not resolve host: vwnd.1990.00
curl: (6) Could not resolve host: 18.nc

Can you please help me.

Rahul
  • 13,309
  • 3
  • 43
  • 54

1 Answers1

2

Remove the double-quotes from the loop items in the for lines - you're iterating over single strings ("air hgt rhum uwnd vwnd" and "00 06 12 18"), not lists of items.

Also, type is a reserved word in bash. Use another variable name, e.g. t, instead.

Finally, you should always double-quote your variables when you use them.

Putting that all together, try this:

export ICTP_DATASITE='http://clima-dods.ictp.it/data/Data/RegCM_Data/EIN15/1990/'

for t in air hgt rhum uwnd vwnd; do
    for hh in 00 06 12 18; do
       curl -o "${t}.1990.${hh}.nc" \
       "${ICTP_DATASITE}/EIN15/1990/${t}.1990.${hh}.nc"
    done
done
cas
  • 1
  • 7
  • 119
  • 185