小编rob*_*ntw的帖子

使用 HERE 文件并重定向命令的输出

我在批处理脚本中有以下代码:

mpirun -np 6 ./laplace <<END
100
100
100
0.01
100
3
2
1
END
| tail -n 1 > output
Run Code Online (Sandbox Code Playgroud)

但它不起作用。我想要它做的是使用 HERE 文件作为 mpirun 命令的输入,然后将输出通过管道传输到 tail 命令。但是,我认为 HERE 文件和尾部输出的东西变得混乱了。

我应该如何写这个才能让它做我想要的?

shell io-redirection

11
推荐指数
2
解决办法
5409
查看次数

从命令行替换文件中的整行

我有一个文本文件,其中有一些与此类似的内容:

# General information about the project.
project = u'Py6S'
copyright = u'2012, Robin Wilson'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.5'
# The full version, including alpha/beta/rc tags.
release = '0.5'
Run Code Online (Sandbox Code Playgroud)

我想version = '0.5'version = X其中 X 是给脚本的命令行参数替换该行,然后对该release =行执行相同的操作。

我可以调用一个简单的命令来进行这种替换吗?我已经研究sed了一下,但似乎 sed …

command-line sed string line-editor replace

5
推荐指数
1
解决办法
3172
查看次数