在shell中,如何在字符串中提取数字

时间:2018-06-14 14:36:26

标签: shell

事实上,我想使用正则表达式来提取shell中Total Execution time:。有人可以帮我解决这个问题吗?

这是目标字符串:

Val Loss:   20.032490309035197
Val Accuracy:   0.13
SystemML Statistics:
Total elapsed time:     80.698 sec.
Total compilation time:     1.325 sec.
Total execution time:       79.373 sec.
Number of compiled MR Jobs: 0.
Number of executed MR Jobs: 0.
Cache hits (Mem, WB, FS, HDFS): 141449/0/0/2.
Cache writes (WB, FS, HDFS):    22097/0/0.
Cache times (ACQr/m, RLS, EXP): 0.151/0.024/0.285/0.000 sec.
HOP DAGs recompiled (PRED, SB): 0/1802.
HOP DAGs recompile time:    1.649 sec.
Functions recompiled:       1.
Functions recompile time:   0.006 sec.
Paramserv func number of workers:   1.
Paramserv func total gradients compute time:    38.000 secs.
Paramserv func total aggregation time:  29.604 secs.
Paramserv func model broadcasting time: 0.008 secs.
Paramserv func total batch slicing time:    0.000 secs.
Total JIT compile time:     20.714 sec.
Total JVM GC count:     228.
Total JVM GC time:      3.195 sec.

1 个答案:

答案 0 :(得分:1)

您可以使用此awk命令:

awk '/Total execution time:/{print $(NF-1)}' file

79.373