I have several folders each containing several .nc
files. I want to loop through all folders and for each folder do some calculations (mergetime) using cdo
on files that have similar pattern. So far I have written the following:
for dir in /mnt/meteo_a/africa_cordex/historical/0.44/pr/*/
do
dir=${dir%*/}
echo ${dir##*/}
export dir
cd $dir
pwd
for f in `find . -type f -regex /(.*?\day)/*`
cdo mergetiem io
done
done
The files in each folder have names like the following:
pr_AFR-44_CNRM-CERFACS-CNRM-CM5_historical_r1i1p1_CLMcom-CCLM4-8-17_v1_day_19500101-19501231.nc
pr_AFR-44_CNRM-CERFACS-CNRM-CM5_historical_r1i1p1_CLMcom-CCLM4-8-17_v1_day_19510101-19551231.nc
pr_AFR-44_ICHEC-EC-EARTH_historical_r12i1p1_CLMcom-CCLM4-8-17_v1_day_19491201-19501231.nc
pr_AFR-44_ICHEC-EC-EARTH_historical_r12i1p1_CLMcom-CCLM4-8-17_v1_day_19510101-19551231.nc
I want to apply the mergetime CDO command on all files that have similar pattern before _day_
.
I want to merge the first two files and the last two files. More specifically, merge files that start with
"pr_AFR-44_CNRM-CERFACS-CNRM-CM5_historical_r1i1p1_CLMcom-CCLM4-8-17_v1_"
and likewise merge files that start with
"pr_AFR-44_ICHEC-EC-EARTH_historical_r12i1p1_CLMcom-CCLM4-8-17_v1"
The output of the mergetime can be something like:
{pattern}_mergetime.nc
find
command. Please show a list of files with some matching and some non-matching files and state which ones you want to select or which files belong into the same group(s). What exactly means "similar pattern before_day_
"? – Bodo Feb 12 '19 at 12:19cdo
, and I found out that themergetime
operator requires the name of theoutfile
. The required arguments are as follows:cdo mergetime one_or_more_input_files one_outfile
. So, what or how do you want to name your output files? – Niko Gambt Feb 12 '19 at 13:16