我正在远程服务器上运行以下脚本。
awk '{sub(/.nc$/, ""); print}' Time012010star.txt > Star.txt #remove .nc
awk '{sub(/.nc$/, ".nc.gz"); print}' Time012010star.txt > StarGZ.txt # add .gz
TempsModel=$(wc -l < TempsModel.txt) #"$(ls -lq *_??????.nc | wc -l)"
outputNumber=$(wc -l < Time012010star.txt)
UarrI1=$(sed -n $index'p' uI1.txt)
UarrI2=$(sed -n $index'p' uI2.txt)
UarrJ1=$(sed -n $index'p' uJ1.txt)
UarrJ2=$(sed -n $index'p' uJ2.txt)
VarrI1=$(sed -n $index'p' vI1.txt)
VarrI2=$(sed -n $index'p' vI2.txt)
VarrJ1=$(sed -n $index'p' vJ1.txt)
VarrJ2=$(sed -n $index'p' vJ2.txt)
TarrI1=$(sed -n $index'p' tI1.txt)
TarrI2=$(sed -n $index'p' tI2.txt)
TarrJ1=$(sed -n $index'p' tJ1.txt)
TarrJ2=$(sed -n $index'p' tJ2.txt)
# from all the netcdf files extract the vel_u (and eventually vel_v) with the indices that are in *I1.txt and *J1.txt
for ((index=1; index<=$outputNumber; index++)) #size de I.txt
do
TimeNC=$(sed -n $index'p' Time012010star.txt) #TempsModel.txt
Time=$(sed -n $index'p' Star.txt)
TimeGZ=$(sed -n $index'p' StarGZ.txt)
scp -r /home/elisev/QUANTUM/Jan2010/${TimeGZ} /home/elisev/ScriptsLinux/SOLA/Scripts/${TimeGZ} #copy remote file locally
gunzip /home/elisev/ScriptsLinux/SOLA/Scripts/${TimeGZ}
ncrcat -C -F -d nj_u,$UarrJ1,$UarrJ2 -d ni_u,$UarrI1,$UarrI2 -v vel_u /${TimeNC} u${Time}.nc
ncrcat -C -F -d nj_v,$VarrJ1,$VarrJ2 -d ni_v,$VarrI1,$VarrI2 -v vel_v /${TimeNC} v${Time}.nc
ncrcat -C -F -d nj_w,$TarrJ1,$TarrJ2 -d ni_w,$TarrI1,$TarrI2 -v w /${TimeNC} w${Time}.nc
ncrcat -C -F -d nj_t,$TarrJ1,$TarrJ2 -d ni_t,$TarrI1,$TarrI2 -v sal /${TimeNC} sal${Time}.nc
ncrcat -C -F -d nj_t,$TarrJ1,$TarrJ2 -d ni_t,$TarrI1,$TarrI2 -v tem /${TimeNC} tem${Time}.nc
echo "${Time}"
rm /home/elisev/ScriptsLinux/SOLA/Scripts/${TimeNC}
done
echo "Loop is done"
它正确复制了第一个文件,但随后出现以下错误
ncrcat: WARNING not searching for /20100101_0020*.nc on remote filesystem, using local file 0100101_0020*.nc instead
ncrcat: WARNING not searching for /20100101_0020*.nc on remote filesystem, using local file 0100101_0020*.nc instead
ncrcat: WARNING not searching for /20100101_0020*.nc on remote filesystem, using local file 0100101_0020*.nc instead
ncrcat: WARNING not searching for /20100101_0020*.nc on remote filesystem, using local file 0100101_0020*.nc instead
ncrcat: WARNING not searching for /20100101_0020*.nc on remote filesystem, using local file 0100101_0020*.nc instead
它确实创建了文件,但我不知道是什么,因为我似乎没有任何名为 0100101_0020*.nc 的文件。我该如何解决这个问题?
答案1
我找到了解决方案。显然,即使您在所有文件夹所在的同一目录中运行脚本,您也需要明确告诉它文件夹的路径,因此这些行
ncrcat -C -F -d nj_u,$UarrJ1,$UarrJ2 -d ni_u,$UarrI1,$UarrI2 -v vel_u /${TimeNC} u${Time}.nc
需要成为
crcat -C -F -d nj_u,$UarrJ1,$UarrJ2 -d ni_u,$UarrI1,$UarrI2 -v vel_u path/to/file/${TimeNC} u${Time}.nc