我需要从iperf日志文件输出中提取最高值,忽略第7行中的第一个条目。
------------------------------------------------------------
Client connecting to 10.10.10.2, TCP port 5001
TCP window size: 0.02 MByte (default)
------------------------------------------------------------
[ 3] local 10.10.10.1 port 44809 connected with 10.10.10.2 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 2.50 MBytes 21.0 Mbits/sec
[ 3] 1.0- 2.0 sec 2.25 MBytes 18.9 Mbits/sec
[ 3] 2.0- 3.0 sec 2.00 MBytes 16.8 Mbits/sec
[ 3] 3.0- 4.0 sec 2.25 MBytes 18.9 Mbits/sec
[ 3] 4.0- 5.0 sec 2.00 MBytes 16.8 Mbits/sec
[ 3] 5.0- 6.0 sec 2.25 MBytes 18.9 Mbits/sec
[ 3] 6.0- 7.0 sec 2.12 MBytes 17.8 Mbits/sec
[ 3] 7.0- 8.0 sec 2.00 MBytes 16.8 Mbits/sec
[ 3] 8.0- 9.0 sec 2.25 MBytes 18.9 Mbits/sec
[ 3] 9.0-10.0 sec 2.00 MBytes 16.8 Mbits/sec
[ 3] 0.0-10.1 sec 21.8 MBytes 18.0 Mbits/sec
到目前为止我已经
了#!/bin/bash
iperf -c 10.0.0.2 -t 10 -f m -i 1 > /tmp/max.log
sed -i '7d' /tmp/max.log
我现在需要回显结果列18.9中的最高值
答案 0 :(得分:3)
您可以不使用sed
,只需告诉awk忽略第7行的所有内容。
$ awk 'NR > 7 { max = $(NF-1) > max ? $(NF-1) : max } END { print max }' m.txt
18.9