Linux 如何使用iperf从bash输出中获取所选文本

Linux 如何使用iperf从bash输出中获取所选文本,linux,bash,shell,Linux,Bash,Shell,在本例中,如何使用UbuntuLinux14.04从perf输出中仅获取所选文本 ~$ iperf -c xxx.xxx.xxx.xxx -r 创建此输出: ------------------------------------------------------------ Server listening on TCP port 5001 TCP window size: 85.3 KByte (default) -------------------------------------

在本例中,如何使用UbuntuLinux14.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
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
我想在
Mbits/sec

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

$ iperf -c xxx.xxx.xxx.xxx -r -y C
创建此输出:

------------------------------------------------------------ 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
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

是的,它很好用。如何将这两个输出保存在var1和var2中?
iperf_data=$(iperf-c$IP1-r-y c-L 41500 | cut-d','-f9)
如何插入这两个变量i两个独立的变量,如下载和上载?
读取a b<在命令行上工作,但在shell脚本中不工作我得到以下信息:语法错误:重定向unexpected@JohnHenriksen:您是否将脚本的第一行用作
#/bin/bash
?如果是,请告诉我们echo$BASH\u版本的输出。我猜你有
#/bin/sh
,您必须更改它。(你需要学会把你的问题写在一个完整的陈述中,不要在事后要求额外的东西;-)好吗?)祝大家好运。