小编Jul*_*lia的帖子

使用tee和grep将某些输出行保存到文件

我想查看脚本的整个输出,但只将匹配“ vlim”的行保存到新文件。我几乎想通了,但不能完全按照我想要的方式工作。我目前在使用之间陷入困境:

python gmakemovie.test movie.cfg.test --overwrite | tee >(grep vlim) /output.txt
grep vlim output.txt > vlim.txt
Run Code Online (Sandbox Code Playgroud)

要么

python gmakemovie.test movie.cfg.test --overwrite | grep vlim | tee  /output.txt
Run Code Online (Sandbox Code Playgroud)

最上面的选项显示我的整个输出,但也将所有输出复制到output.txt。底部选项仅复制“ vlim”,但不显示其余输出,因此我无法确定脚本中的位置。

为了清楚起见,这就是我的输出:

imported pygad v0.4.32+ga1eacb4.dirty
from parameter file (fragmentary):
  snaps:      200 - 200
  width:      1000.0 [kpc]
  pixel:      500 x 500
  x - y:      x - y
  softening:  [  0.2    0.45   2.52  20.     0.2    0.2 ] [ckpc h_0**-1]
====================================================
get orientation from trace file "filepath":
  L:       [ 241.01309204  544.96875    -366.44366455] [1e+10 ckpc h_0**-1 …
Run Code Online (Sandbox Code Playgroud)

grep tee

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

标签 统计

grep ×1

tee ×1