gpt4 book ai didi

linux - Grep 号码提取

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:46:28 29 4
gpt4 key购买 nike

我需要使用 grep 从具有以下格式的一系列行中提取数值:“总差为:11.7423485766”。

这里是文件的格式

smoothSolver:  Solving for Uax, Initial residual = 0.00117823324374, Final residual = 2.6551659504e-06, No Iterations 4

smoothSolver: Solving for Uay, Initial residual = 0.00102460810826, Final residual = 2.27551114222e-06, No Iterations 4

GAMG: Solving for pa, Initial residual = 0.083060886073, Final residual = 4.42348716834e-05, No Iterations 8

Adjoint continuity errors : sum local = 0.000102057393701, global = -2.79342190934e-05, cumulative = -0.00156476995631

The ratio scalar is 0.00767871345324

The toal volume is 0.01

The percentage of fluid domain is 0.767871345324

omegaVol is 1.331

Total Pressure at the inlet: 18.3146365858

Total Pressure at the outlet: 0.533553352625

The total difference is: 17.7810832332

ExecutionTime = 1.05 s

我试过了

grep "The total difference is:" | cut -d' ' -f9   log

但它似乎不起作用,我不明白为什么。

有什么想法吗?感谢帮助

最佳答案

这个怎么样:

grep "The total difference is:" log | grep -o "[0-9.]*"

第一个 grep 获取整行,包含匹配的文本,第二个只获取数字。

关于linux - Grep 号码提取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53211019/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com