Bash Shell 脚本 - ncrcat NetCDF 运算符

Bash Shell Script - ncrcat NetCDF operators

我有几个文件,我想将它们合并成一个文件。因为我可以使用循环调用文件,所以我想使用命令 ncrcat 来连接它们。我知道在我编写 ncrcat 的方式和位置时,它只包含一个文件,即目前循环中的那个文件,但我想不出别的东西。我的脚本是:

Vars1="Ad Ab Al"
Var2=Bs

for MyVar1 in $MyVars1 ; do

MyFile=${MyVar1}-${Var2}.nc
ncrcat $MyFile AllFiles.nc

done

感谢您的任何回答。

要构造 ncrcat 的文件参数列表,您可以使用命令替换:

ncrcat $(find $NC_FILES_DIR -type f -name '*.nc') out.nc

你在哪里定义 NC_FILES_DIR.

有了 ncrcat,您可以使用正则表达式来查找文件,因此无需遍历变量。

ncrcat A[a-z]-Bs.nc AllFiles.nc 

阅读 regular expressions on nco commands