use*_*018 3 logs text-processing
我正在监视某个问题的收敛历史。历史输出如下:
Time = 24
Calculate volume forces from actuator disk
Total thrust = -8.46832
Total torque = 1.03471
ADisk volume = 0.0632799
smoothSolver: Solving for Ux, Initial residual = 0.000447755, Final residual = 2.68745e-05, No Iterations 2
smoothSolver: Solving for Uy, Initial residual = 0.0107909, Final residual = 0.000812227, No Iterations 2
smoothSolver: Solving for Uz, Initial residual = 0.0103399, Final residual = 0.000786661, No Iterations 2
GAMG: Solving for p, Initial residual = 0.123954, Final residual = 0.00958268, No Iterations 6
time step continuity errors : sum local = 7.42808e-05, global = -4.25546e-05, cumulative = 0.000413527
smoothSolver: Solving for epsilon, Initial residual = 0.00197379, Final residual = 0.000172248, No Iterations 1
smoothSolver: Solving for k, Initial residual = 0.000510499, Final residual = 2.78594e-05, No Iterations 2
ExecutionTime = 124.63 s ClockTime = 125 s
Time = 25
Calculate volume forces from actuator disk
Total thrust = -8.49093
Total torque = 1.03723
ADisk volume = 0.0632799
smoothSolver: Solving for Ux, Initial residual = 0.000409002, Final residual = 2.59552e-05, No Iterations 2
smoothSolver: Solving for Uy, Initial residual = 0.0103191, Final residual = 0.00077024, No Iterations 2
smoothSolver: Solving for Uz, Initial residual = 0.00985658, Final residual = 0.000742227, No Iterations 2
GAMG: Solving for p, Initial residual = 0.0390756, Final residual = 0.00247253, No Iterations 7
time step continuity errors : sum local = 5.39785e-05, global = 3.40394e-05, cumulative = 0.000447566
smoothSolver: Solving for epsilon, Initial residual = 0.00182397, Final residual = 0.000157739, No Iterations 1
smoothSolver: Solving for k, Initial residual = 0.000465916, Final residual = 2.75864e-05, No Iterations 2
ExecutionTime = 129.45 s ClockTime = 130 s
Time = 26
Calculate volume forces from actuator disk
Total thrust = -8.51463
Total torque = 1.03953
ADisk volume = 0.0632799
Run Code Online (Sandbox Code Playgroud)
我想做的是在某个时间复制值,在这种情况下说 at Time=26
,的值
Total thrust = -8.51463
Total torque = 1.03953
Run Code Online (Sandbox Code Playgroud)
格式如下:
1.03953 -8.51463.
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我使用 shell 脚本来做到这一点。
你要求一个 shell 脚本,但希望awk
能做到:
/^Total thrust =/ {thrust = $4}
/^Total torque =/ {torque = $4}
/^Time =/ {if (found) exit; if ($3 == time) found=1}
END {print torque " " thrust}
Run Code Online (Sandbox Code Playgroud)
$ awk -v time=25 -f find_thrust_torque.awk file1
1.03723 -8.49093
$ awk -v time=26 -f find_thrust_torque.awk file1
1.03953 -8.51463
Run Code Online (Sandbox Code Playgroud)