0

I have the variable:

files=$(ls *.nc)

Which contain hourly netcdf files that I want to merge into daily files using cdo. I need to create something like "cdo merge $files[1] $files[2] .... $files[24] all.nc" and run the expression. How can I create this expression in shell?

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86

1 Answers1

1

Based on the information provided, the following might well produce the desired result:

cdo merge *.nc all.nc

In other words, let shell globbing do the work for you. A shell array variable seems unnecessary. But if you insist on using the array, try this

cdo merge "${files[@]}" all.nc
Charlie Zender
  • 5,929
  • 14
  • 19