gpt4 book ai didi

linux - 如何使用 iperf 从 bash 输出中获取选定的文本

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

在此示例中,如何使用 ubuntu linux 14.04 从 perf 输出中仅获取选定的文本。

~$ iperf -c xxx.xxx.xxx.xxx -r

创建此输出:

------------------------------------------------------------ Server listening on TCP port 5001 TCP window size: 85.3 KByte (default)
------------------------------------------------------------
------------------------------------------------------------ Client connecting to xxx.xxx.xxx.xxx, TCP port 5001 TCP window size: 48.1 KByte (default)
------------------------------------------------------------ [ 5] local xxx.xxx.xxx.xxx port 51684 connected with xxx.xxx.xxx.xxx port 5001 [ ID] Interval Transfer Bandwidth [ 5] 0.0-10.0 sec
82.8 MBytes 69.3 Mbits/sec [ 4] local xxx.xxx.xxx.xxx port 5001 connected with xxx.xxx.xxx.xxx port 60267 [ 4] 0.0-10.1 sec 105 MBytes 87.7 Mbits/sec

我想在 Mbits/sec 之前获取 69.387.7.

否则我可以使用获取带宽:

$ iperf -c xxx.xxx.xxx.xxx -r -y C

创建此输出:

20150228152825,192.168.0.50,54278,192.168.0.110,5001,3,0.0-10.0,1034158080,827149205
20150228152835,192.168.0.50,5001,192.168.0.110,59625,5,0.0-10.0,776732672,621025632

并在每行的最后一个逗号 i 之后获取最后一个数字。我只是无法使用 grep、sed 或 awk 解决这个问题。

谁能帮帮我?

最佳答案

cut 会做得很好

iperf -c xxx.xxx.xxx.xxx -r -y C|cut -d',' -f9

关于linux - 如何使用 iperf 从 bash 输出中获取选定的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28795045/

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