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-263944

aaaaa's questions

Martin Hope
aaaaa
Asked: 2021-12-23 01:54:17 +0800 CST

选择文件中具有相同字符串模式的行

  • 0

假设我有以下内容file.txt:

asiub
sj
abq
b aia
ainp oo
test = 123d
sub ,.
aiba 87ab
test = 129szs bq
test = aqua
ayqvq 133s 

我只想打印file.txt包含字符串的行test =。

想要的output.txt:

test = 123d
test = 129szs bq
test = aqua

有什么建议吗?

谢谢

linux shell-script
  • 1 个回答
  • 35 Views
Martin Hope
aaaaa
Asked: 2021-12-09 02:23:08 +0800 CST

只保留文件中出现 n 次的行

  • 0

我有一个test.txt文件,每行包含一个字符串,如下所示:

AA
BNT
AA
KIO
LO
LO
POY
LO
II
LO
AA
AA
II
AA
BNT
POY
YTR
BNT
LL
BNT

如何使用 linux 浏览文件并仅返回出现 4 次的行?

期望的输出:

AA
BNT
LO

谢谢

linux bash
  • 2 个回答
  • 87 Views
Martin Hope
aaaaa
Asked: 2019-07-02 01:48:47 +0800 CST

带索引的for循环[重复]

  • 1
这个问题在这里已经有了答案:
如何在序列的 shell 大括号扩展中使用 $variable? (5 个回答)
3年前关闭。

假设我有以下循环:

for i in {1..3}
do

mkdir $i

done

由于我在主代码中有许多其他循环,并且我将定期更改序列的大小,因此我想定义循环的startandend并在 for 循环中使用这些变量。

我试过这个没有成功:

start=1;
end=1;

for i in {$start..$end}
do

mkdir $i

done

有什么建议吗?

bash for
  • 1 个回答
  • 891 Views
Martin Hope
aaaaa
Asked: 2017-12-03 07:52:49 +0800 CST

使用 shell 脚本安装 ncdf4 R 包

  • 0

我正在尝试ncdf4使用由 shell 脚本运行的 R 脚本将 R 包安装到远程计算机中。

我尝试安装其他软件包,它工作正常,但ncdf4它没有软件包。

我的 R 脚本如下:

install.packages('ncdf4', repos = "http://cran.us.r-project.org")

shell脚本的输出是:

^LInstalling package into ‘/my/directory/R/x86_64-pc-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'http://cran.us.r-project.org/src/contrib/ncdf4_1.16.tar.gz'
Content type 'application/x-gzip' length 121420 bytes (118 KB)
==================================================
downloaded 118 KB

* installing *source* package ‘ncdf4’ ...
** package ‘ncdf4’ successfully unpacked and MD5 sums checked
configure.ac: starting
checking for nc-config... no
-----------------------------------------------------------------------------------
Error, nc-config not found or not executable.  This is a script that comes with the
netcdf library, version 4.1-beta2 or later, and must be present for configuration
to succeed.

If you installed the netcdf library (and nc-config) in a standard location, nc-config
should be found automatically.  Otherwise, you can specify the full path and name of
the nc-config script by passing the --with-nc-config=/full/path/nc-config argument
flag to the configure script.  For example:

./configure --with-nc-config=/sw/dist/netcdf4/bin/nc-config

Special note for R users:
-------------------------
To pass the configure flag to R, use something like this:

R CMD INSTALL --configure-args="--with-nc-config=/home/joe/bin/nc-config" ncdf4

where you should replace /home/joe/bin etc. with the location where you have
installed the nc-config script that came with the netcdf 4 distribution.
-----------------------------------------------------------------------------------
ERROR: configuration failed for package ‘ncdf4’
* removing ‘/my/directory/R/x86_64-pc-linux-gnu-library/3.3/ncdf4’

The downloaded source packages are in
        ‘/tmp/RtmpJLxXFq/downloaded_packages’
Warning message:
In install.packages("ncdf4", repos = "http://cran.us.r-project.org") :
  installation of package ‘ncdf4’ had non-zero exit status
Error in library(ncdf4) : there is no package called ‘ncdf4’
Execution halted

你以前遇到过这个问题吗?有什么建议吗?

谢谢

shell package-management
  • 1 个回答
  • 3364 Views
Martin Hope
aaaaa
Asked: 2017-12-03 02:47:23 +0800 CST

通过 shell 脚本运行 R 脚本。意外标记 `(' 附近的语法错误

  • 1

我目前正在尝试通过 shell 脚本运行 R 脚本。

这里是 R 脚本:

test = rnorm(1:100, 1000)
write.csv(test, 'test.csv')

这里是调用 R 的 bash 脚本:

#!/bin/bash -l
#SBATCH --partition=compute
#SBATCH --job-name=test
#SBATCH --mail-type=ALL
#SBATCH [email protected]
#SBATCH --time=00:10:00
#SBATCH --nodes=1
#SBATCH --tasks-per-node=12
#SBATCH --account=myaccount
module purge
module load R
${HOME}/test.R

我想我做的一切都正确,但输出返回以下错误:

/mydirectory/test.R: line 3: syntax error near unexpected token `('
/mydirectory/test.R: line 3: `test = rnorm(1:100, 1000)'

为什么我会收到此错误?

bash shell-script
  • 1 个回答
  • 8791 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