I am trying to use multiple inputs at the same files in a command as an output, from this question I made
looping object as inputs in BASH, SHELL script
The user Konsolebox and all the others were very helpful in giving me to understand how the process may be improved and operate. After their suggestion I took their inputs and tried to alter my code, although it does not seem to work.
The code's job is to take multiple items with difference in time and/or months and input them as input files to a bash command which will produce one single output file
The suggestions proposed made me alter the code this way:
fname2="trim"
years=({2000..2010})
months=(01 02) ## ({01..100}) should be the same
end="nc"
I have been trying to make it work but no matter what i change i get the same error
cdo mergetime: Open failed on >@({2010})@(01<
No such file or directory
I have placed the bash script in the working folder and the files are named trim201001.nc
and trim201002.nc
(usually i will have hundreds with that format that is why i am trying to automatize them)
I am running the script with the command ./script.sh
after the advice of konsolebox i added shopt -s nullglob
shopt -s extglob
shopt -s nullglob
#IFS='|' eval 'pattern="${fname2}@(${years[*]})@(${months[*]}).${end}"'
IFS='|' eval 'pattern="${fname2}$years@(${months[*]}).${end}"'
echo "pattern = ${pattern}"
files=($pattern) ## pathname expansion is sorted in Bash.
cdo mergetime "${files[@]}" ofile
And the new error i think is located in the month reading, although i checked my location the one file that is to be use is 02 (month) and 01 (month)
pattern = @(2010)@(01|02).nc
cdo mergetime: Open failed on >02).nc<
No such file or directory