我是Linux和bash的新手。我从Iperf网络性能和吞吐量工具中捕获了文件。文件很大,所以我没有附上它。但它看起来像这样:
bin/iperf.exe -s -P 0 -i 1 -p 5001 -w 8192.0K -N -f m
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 8.00 MByte
------------------------------------------------------------
[148] local 192.168.0.14 port 5001 connected with 192.168.0.12 port 49504
[260] local 192.168.0.14 port 5001 connected with 192.168.0.12 port 49501
[276] local 192.168.0.14 port 5001 connected with 192.168.0.12 port 49502
[292] local 192.168.0.14 port 5001 connected with 192.168.0.12 port 49503
[ ID] Interval Transfer Bandwidth
[148] 0.0- 1.0 sec 0.00 MBytes 0.00 Mbits/sec
[148] 1.0- 2.0 sec 0.00 MBytes 0.00 Mbits/sec
[148] 2.0- 3.0 sec 0.01 MBytes 0.07 Mbits/sec
[276] 0.0- 1.0 sec 2.67 MBytes 22.4 Mbits/sec
[SUM] 0.0- 3.0 sec 2.68 MBytes 7.49 Mbits/sec
[292] 0.0- 1.0 sec 3.21 MBytes 26.9 Mbits/sec
[148] 3.0- 4.0 sec 1.75 MBytes 14.7 Mbits/sec
[260] 0.0- 1.0 sec 1.86 MBytes 15.6 Mbits/sec
[292] 1.0- 2.0 sec 5.08 MBytes 42.6 Mbits/sec
[SUM] 0.0- 4.0 sec 11.9 MBytes 25.0 Mbits/sec
[148] 4.0- 5.0 sec 1.10 MBytes 9.25 Mbits/sec
[276] 1.0- 2.0 sec 2.59 MBytes 21.7 Mbits/sec
[260] 1.0- 2.0 sec 1.21 MBytes 10.2 Mbits/sec
[292] 2.0- 3.0 sec 1.65 MBytes 13.9 Mbits/sec
[SUM] 1.0- 5.0 sec 6.56 MBytes 13.8 Mbits/sec
[260] 2.0- 3.0 sec 1.97 MBytes 16.5 Mbits/sec
[276] 2.0- 3.0 sec 3.42 MBytes 28.7 Mbits/sec
[148] 5.0- 6.0 sec 1.81 MBytes 15.2 Mbits/sec
[260] 3.0- 4.0 sec 2.09 MBytes 17.5 Mbits/sec
[SUM] 2.0- 6.0 sec 9.29 MBytes 19.5 Mbits/sec
然后我们有类似模式的大量数据。我想找到最高和最低的" Mbits / sec"来自文件的值。此文件可以保存为.txt或.csv(如果有帮助)。我尝试过某种类型和awk过滤器实验,但直到现在还没有用。
我试过的排序过滤器是
答案 0 :(得分:1)
这样的事情会起作用:
awk '/^\[SUM]/ {
min = !min || $7 < min ? $7 : min
max = $7 > max ? $7 : max
} END { print "min:", min, "max:", max }' file
当[SUM]在行的开头匹配时,如有必要,使用三元运算符覆盖最小值和最大值。处理完文件后,打印最小值和最大值。
输出:
min: 7.49 max: 25.0