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
    • 最新
    • 标签
主页 / user-334419

Jellyse's questions

Martin Hope
Jellyse
Asked: 2019-08-27 01:09:06 +0800 CST

ncrcat:警告不在远程文件系统上搜索 /*.nc,而是使用本地文件 *.nc

  • 0

我在远程服务器上运行以下脚本。

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 的文件。我该如何解决这个问题?

linux
  • 1 个回答
  • 31 Views
Martin Hope
Jellyse
Asked: 2019-07-18 03:20:00 +0800 CST

从文件名中删除星号

  • 1

我有一堆看起来像这样的文件名:

2501254200*.nc

我想删除星号。但是当我使用以下代码时:

mmv '***' '#1#2' 

我得到错误

2501254200*.nc -> : bad new name

Nothing done

如何从名称中删除 *?

rename
  • 2 个回答
  • 1338 Views
Martin Hope
Jellyse
Asked: 2019-06-28 05:55:38 +0800 CST

删除txt文件中字符串的最后一个字符

  • 1

我有一个名为的文件TempsModel.txt,其创建方式如下:

ls /media/Elise/2811226E69F71131/ModelOutput/* > TempsModel.txt

所以它列出了该目录中的所有文件。这些文件都是压缩的 netcdf 文件,所以看起来像这样:

/media/Elise/2811226E69F71131/ModelOutput/20091201_000000.nc.gz
/media/Elise/2811226E69F71131/ModelOutput/20091201_002023.nc.gz
/media/Elise/2811226E69F71131/ModelOutput/20091201_003009.nc.gz
/media/Elise/2811226E69F71131/ModelOutput/20091201_004020.nc.gz

我需要这个列表不包含.gz. 如何删除这三个字符?我尝试了使用 shell 脚本中的字符串操作删除字符串的最后一个字符和从行中删除最后一个字符的问题

但是如何创建TempsModel2.txt列表不包含最后三个字符的第二个文件?

linux text-processing
  • 2 个回答
  • 170 Views
Martin Hope
Jellyse
Asked: 2019-06-18 00:53:37 +0800 CST

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

  • 0

我有一个用于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 个回答
  • 82 Views
Martin Hope
Jellyse
Asked: 2019-05-29 04:04:19 +0800 CST

从某行开始写入文件

  • 1

我有一个看起来像这样的文件:

**********************************
Some notes are here
Year Month Day Hour Minute Second
. . . . . . . . . . . . . . . . .

在此之下,我希望使用以下代码显示日期

#!/bin/bash
for  timestamp in (1262300400..1264978800..600)
do
date -d @"$timestamp" '+%Y %m %d %H %M %S';
done | grep -Ev '[15]0 00$' > file.txt

如果您想知道我是如何获得此代码的,请阅读问题Range of dates with minutes 这个问题的难点是最后一部分"> file.txt"。当前代码会覆盖 file.txt 中已有的内容。我希望这个循环在文件'file.txt'的注释下面打印日期,所以让它开始写可以说是第5行或其他东西。

所以所需的输出将是

**********************************
Some notes are here
Year Month Day Hour Minute Second
. . . . . . . . . . . . . . . . .
2010 01 01 00 00 00
2010 01 01 00 20 00
2010 01 01 00 30 00
2010 01 01 00 40 00
2010 01 01 01 00 00 
linux write
  • 1 个回答
  • 72 Views
Martin Hope
Jellyse
Asked: 2019-05-29 00:47:39 +0800 CST

计算具有特定名称的目录中的文件数

  • 5

我在这里找到了这段代码https://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x700.html这很好地给了我目录中的文件数量。

ls -1 | wc -l

但我只想知道这些文件中有多少以 2009 开头(例如20091210_005037.nc)。

我试过ls -1 | wc -l 2009*了,但这会慢慢列出所有文件,似乎没有给我一个数字。

ls wc
  • 4 个回答
  • 19637 Views
Martin Hope
Jellyse
Asked: 2019-05-23 05:45:33 +0800 CST

带分钟的日期范围

  • 0

我正在尝试创建从 01/01/2010 到 01/02/2010 的一系列日期,其中分钟的距离不均匀,如下所示:

2010  1  1  00  00  00
2010  1  1  00  20  00
2010  1  1  00  30  00
2010  1  1  00  40  00
2010  1  1  01  00  00
2010  1  1  01  20  00
2010  1  1  01  30  00
2010  1  1  01  40  00

...
2010  2  1  00  00  00

所以在第 00 分钟、第 20 分钟、第 30 分钟和第 40 分钟,每隔一小时,直到结束日期。我找到了有问题的帮助https://stackoverflow.com/questions/15621409/print-dates-in-date-range-linux 但我无法添加分钟,更不用说空格而不是'-'和不均匀脚步。到目前为止,这是我的代码,它不起作用:

startdate=2010-01-01-00-00-00
enddate=2010-02-01-00-00-00

curr="$startdate"
while true; do
    echo "$curr"
    [ "$curr" \< "$enddate" ] || break
    curr=$( date +%Y-%m-%d-%H-%M-%S --date "$curr +10 minutes" )
done

如何以中间有空格的间隔创建上面的输出?

linux date
  • 1 个回答
  • 57 Views
Martin Hope
Jellyse
Asked: 2019-05-01 00:43:45 +0800 CST

变量的长度

  • 0

我从文本文件中导入了纬度和经度。这两个文本文件包含几千个数字。我将它们读入变量,现在我想知道这些文件中有多少个数字。我使用了这个问题:验证变量的长度,但由于某种原因,我得到的输出是length of Lat is 1.

#!/bin/sh

mapfile Latitude < final_ADCP_Saved.matLatitude.txt
mapfile Longitude < final_ADCP_Saved.matLongitude.txt


echo "length of Lat is ${#Latitude[@]}"
echo "length of Lon is ${#Longitude[@]}"

如果我说echo "$Longitude输出是

3.4269394e+00   3.4240913e+00   3.4212670e+00   3.4184430e+00   3.4156012e+00   3.4126834e+00   3.4097271e+00   3.4069235e+00   3.4041572e+00   3.4010903e+00   3.3982218e+00   3.3953517e+00   3.3925018e+00   3.3897342e+00   3.3868243e+00   3.3839234e+00   3.3810560e+00

如何确定这些变量的长度?

linux variable
  • 1 个回答
  • 384 Views
Martin Hope
Jellyse
Asked: 2019-03-09 03:05:26 +0800 CST

netcdf 文件中的长度变量

  • 0

我想知道 netcdf 文件“122009.nc”中变量“i”的长度。到目前为止,这是我的脚本:

#!bin/bash
var=ncdump -v i 122009.nc
var_length=${#var}
variable
  • 1 个回答
  • 92 Views
Martin Hope
Jellyse
Asked: 2019-02-01 07:57:40 +0800 CST

用连续数字重命名文件[重复]

  • 1
这个问题在这里已经有了答案:
将文件批量重命名为顺序编号 5 个答案
3年前关闭。

我有大约一千个文件,看起来都像这样:

20091208170014.nc              
20091211150704.nc  
20091214131328.nc  
20091217111953.nc  
20091220092643.nc  
20091223073308.nc  
20091226053932.nc  
20091229034557.nc
20091208171946.nc              
20091211152610.nc

前八位是日期,后六位是连续数字,但这些数字之间的差异在文件之间并不相同。我希望最后六个数字是连续的并且始终使用相同的步骤。例如:

20091208000001.nc              
20091211000002.nc  
20091214000003.nc  
20091217000004.nc  
20091220000005.nc  
20091223000006.nc  
20091226000007.nc  
20091229000008.nc
20091208000009.nc              
20091211000010.nc

我使用https://www.ostechnix.com/how-to-rename-multiple-files-at-once-in-linux/mmv等其他问题检查了该站点上的几个问题,但没有一个可以向我解释如何拥有我名字中的连续数字。

为了将此与问题Batch rename files to a sequence numbering区分开来,顺序排序必须基于最后六位数字,完全忽略前八个字符中的嵌入日期。

rename
  • 2 个回答
  • 1741 Views

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