没有权限; ,既不在本地也不匹配远程文件名模式

没有权限; ,既不在本地也不匹配远程文件名模式

我有一个代码用于从多个文件ncrcat中提取值。.nc在一个循环中,我要求这段代码一次从一个文件中提取。这些文件的名称存储在文本文件中。看来,由于这些文件存储在不同的目录中,因此即使我添加路径,代码也无法读取它们。这是代码:

#!/bin/bash

outputNumber="$(wc -l Time122009.txt)"  #"$(ls -lq *_??????.nc | wc -l)"

echo "the number of lines in the Time text file is ${outputNumber}"

# from all the netcdf files extract the vel_u (and eventually vel_v) with the indices that are in I.txt and J.txt
for ((index=1; index<=10; index++)) #for now only 10 loops were done, the 10 should eventually be replaced by outputNumber 
do
arrI1=$(sed -n $index'p' I1.txt)
arrI2=$(sed -n $index'p' I2.txt)

arrJ1=$(sed -n $index'p' J1.txt)
arrJ2=$(sed -n $index'p' J2.txt)

Addition=`expr $index + 253` #I want it to start reading file Time122009.txt at position 253
Time=$(sed -n $Addition'p' Time122009.txt)

        ncrcat -C -F -d nj_u,${arrJ1},${arrJ2} -d ni_u,${arrI1},${arrI2} -v vel_u $(../GRAPHIQUES/${Time}) $index.nc #extract from variable vel_u in dimensions nj_u and ni_u from file found in Time

done

I.txt 和 J.txt 的第一个值如下所示:

5.2000000e+02
5.1000000e+02
4.9800000e+02
4.9200000e+02
4.8600000e+02
4.8000000e+02
4.7600000e+02

Time122009.txt 看起来像这样

20091207_142???.nc
20091207_143???.nc
20091207_144???.nc
20091207_150???.nc
20091207_152???.nc
20091207_153???.nc
20091207_154???.nc

这是输出:

the number of lines in the Time text file is 378 Time122009.txt
    ./geknoei.sh: line 30: ../GRAPHIQUES/20091209_080725.nc: Permission denied
    , neither exists locally nor matches remote filename patterns
    ./geknoei.sh: line 30: ../GRAPHIQUES/20091209_082632.nc: Permission denied
    , neither exists locally nor matches remote filename patterns
    ./geknoei.sh: line 30: ../GRAPHIQUES/20091209_083???.nc: No such file or directory
    , neither exists locally nor matches remote filename patterns
    ./geknoei.sh: line 30: ../GRAPHIQUES/20091209_084604.nc: Permission denied
    , neither exists locally nor matches remote filename patterns
    ./geknoei.sh: line 30: ../GRAPHIQUES/20091209_090511.nc: Permission denied
    , neither exists locally nor matches remote filename patterns
    ./geknoei.sh: line 30: ../GRAPHIQUES/20091209_092443.nc: Permission denied
    , neither exists locally nor matches remote filename patterns
    ./geknoei.sh: line 30: ../GRAPHIQUES/20091209_093???.nc: No such file or directory
    , neither exists locally nor matches remote filename patterns
    ./geknoei.sh: line 30: ../GRAPHIQUES/20091209_094350.nc: Permission denied
    , neither exists locally nor matches remote filename patterns
    ./geknoei.sh: line 30: ../GRAPHIQUES/20091209_100257.nc: Permission denied
    , neither exists locally nor matches remote filename patterns
    ./geknoei.sh: line 30: ../GRAPHIQUES/20091209_102229.nc: Permission denied
    , neither exists locally nor matches remote filename patterns

找不到某些文件(没有该文件或目录)是正常的。

我的脚本的路径是:/home/elisev/SYMPHONIE2015/ROC_CONNECT/Scripts 我的文件的路径是:/home/elisev/SYMPHONIE2015/ROC_CONNECT/GRAPHIQUES 如何阻止这些错误发生,以便它可以很好地提取我需要的内容?

编辑:删除$()周围$(../GRAPHIQUES/${Time})消除了权限被拒绝的错误。现在错误只是这样:

, neither exists locally nor matches remote filename patterns
, neither exists locally nor matches remote filename patterns
, neither exists locally nor matches remote filename patterns
, neither exists locally nor matches remote filename patterns
, neither exists locally nor matches remote filename patterns
, neither exists locally nor matches remote filename patterns
, neither exists locally nor matches remote filename patterns
, neither exists locally nor matches remote filename patterns
, neither exists locally nor matches remote filename patterns
, neither exists locally nor matches remote filename patterns

答案1

我遇到的问题是文件 I.txt 和 J.txt 中数字的格式。需要是整数(520而不是5.2000000e+02)一旦我改变了(通过dlmwrite('myFile.txt', myMatrix);在matlab中使用)我的代码看起来像这样并且可以工作:

outputNumber="$(wc -l Time122009.txt)"  #"$(ls -lq *_??????.nc | wc -l)"

echo "the number of lines in the Time text file is ${outputNumber}"

# from all the netcdf files extract the vel_u (and eventually vel_v) with the indices that are in I.txt and J.txt
for ((index=1; index<=10; index++)) #size de I.txt 
do
arrI1=$(sed -n $index'p' I1.txt)
arrI2=$(sed -n $index'p' I2.txt)

arrJ1=$(sed -n $index'p' J1.txt)
arrJ2=$(sed -n $index'p' J2.txt)

Addition=`expr $index + 253` 
Time=$(sed -n $Addition'p' Time122009.txt) #TempsModel.txt
        echo $Addition
        ncrcat -C -F -d nj_u,$arrJ2,$arrJ2 -d ni_u,$arrI1,$arrI2 -v vel_u /home/elisev/SYMPHONIE2015/ROC_CONNECT/GRAPHIQUES/${Time} $index.nc 
        echo "${Time}"
done

相关内容