gpt4 book ai didi

linux - 根据shell脚本中的第一列计算第二列的平均值

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:12:45 24 4
gpt4 key购买 nike

<分区>

我有一个这样的输入日志文件:

CLASS:CLASS1, CREATE_TIME:30-Dec-2015 00:00:06, VALID_AFTER_TIME:30-Dec-2015 00:00:12, EVAL_TIME:30-Dec-2015 00:00:12, SUCCESS:true, TIME_TAKEN:1842
CLASS:CLASS1, CREATE_TIME:30-Dec-2015 00:00:06, VALID_AFTER_TIME:30-Dec-2015 00:00:12, EVAL_TIME:30-Dec-2015 00:00:12, SUCCESS:true, TIME_TAKEN:1842
CLASS:CLASS2, CREATE_TIME:30-Dec-2015 00:00:06, VALID_AFTER_TIME:30-Dec-2015 00:00:12, EVAL_TIME:30-Dec-2015 00:00:12, SUCCESS:true, TIME_TAKEN:1842
CLASS:CLASS1, CREATE_TIME:30-Dec-2015 00:00:06, VALID_AFTER_TIME:30-Dec-2015 00:00:12, EVAL_TIME:30-Dec-2015 00:00:12, SUCCESS:true, TIME_TAKEN:1842
CLASS:CLASS2, CREATE_TIME:30-Dec-2015 00:00:06, VALID_AFTER_TIME:30-Dec-2015 00:00:12, EVAL_TIME:30-Dec-2015 00:00:12, SUCCESS:true, TIME_TAKEN:1842
CLASS:CLASS1, CREATE_TIME:30-Dec-2015 00:00:06, VALID_AFTER_TIME:30-Dec-2015 00:00:12, EVAL_TIME:30-Dec-2015 00:00:12, SUCCESS:true, TIME_TAKEN:1842

我想计算每个类(class)的平均时间。例如我想要这样的输出:

CLASS1 5.5
CLASS2 13

我正在使用以下方法提取 名称时间,但无法计算平均值。

awk -F'[,:]' '{print $25 " " $41;}' modified_01.log | sort 

输出:

CLASS:CLASS1 10
CLASS:CLASS1 1
CLASS:CLASS2 9
CLASS:CLASS1 10
CLASS:CLASS2 17
CLASS:CLASS1 1

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