拜托,我需要帮助通过使用来自两个不同路径的两个不同变量来更正此 .sh 脚本。 谢谢你的帮助!
我试过了,但没用:
#!/bin/bash
path1="cd /work/bk1088/b382227/pidata/monpctl75"
path2="cd /work/bk1088/b382227/pidata/monpctl25"
for i in "path1/*.nc" and v in "path2/*.nc"; do
cdo -a sub ${i} ${v} /work/bk1088/b382227/pidata/IQR-75sub25/${i}_iqr.nc
done
简单:
#!/bin/bash
path1="/work/bk1088/b382227/pidata/monpctl75"
path2="/work/bk1088/b382227/pidata/monpctl25"
for i in "$path1"/*.nc; do
for v in "$path2"/*.nc; do
cdo -a sub "$i" "$v" "/work/bk1088/b382227/pidata/IQR-75sub25/${i}_iqr.nc"
done
done
我假设您想将 path1 中的一个文件与 path2 中的相应文件匹配(不是所有 path1 文件和 path2 文件的叉积)。
#!/bin/bash
pidata=/work/bk1088/b382227/pidata
files1=( "$pidata"/monpctl75/*.nc )
files2=( "$pidata"/monpctl25/*.nc )
for idx in "${!files1[@]}"; do
i=${files1[idx]}
v=${files2[idx]}
cdo -a sub "$i" "$v" "$$pidata/IQR-75sub25/${i}_iqr.nc"
done