AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 525368
Accepted
Jellyse
Jellyse
Asked: 2019-06-18 00:53:37 +0800 CST2019-06-18 00:53:37 +0800 CST 2019-06-18 00:53:37 +0800 CST

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

  • 772

我有一个用于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
linux
  • 1 1 个回答
  • 82 Views

1 个回答

  • Voted
  1. Best Answer
    Jellyse
    2019-06-20T00:03:02+08:002019-06-20T00:03:02+08:00

    我遇到的问题是 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
    
    • 0

相关问题

  • 有没有办法让 ls 只显示某些目录的隐藏文件?

  • 使用键盘快捷键启动/停止 systemd 服务 [关闭]

  • 需要一些系统调用

  • astyle 不会更改源文件格式

  • 通过标签将根文件系统传递给linux内核

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve