I am trying to extract certain variables from netcdf files. The following code works if I apply it to a single file:
ncks -C -F -d nj_u,151,152,1 ni_u,234,235,1 -v vel_u 20091208000001.nc testU.nc
See also question: Hyperslab of a 4D netcdf variable using ncks for explanation. Now I want to use this code on several .nc files with following names:
20091208000001.nc
20091208000002.nc
20091208000003.nc
I tried the following loop:
# !bin/bash
for ((x=1;x<=3;x+=1))
do
ncks -C -F -d nj_u,151,152,1 ni_u,234,235,1 -v vel_u 2009120800000$x.nc testU.nc
done
I get the error
ncks: ERROR received 4 filenames; need no more than two
How do I get the loop to only extract from one file at a time and then append the extracted output from all the files into a single output file?