Grep 使用iperf时删除某些行
我按如下方式运行iperf命令:Grep 使用iperf时删除某些行,grep,iperf,Grep,Iperf,我按如下方式运行iperf命令: iperf -c 10.0.0.1 -t 2 -f m -w 1K | grep -Po '[0-9.]*(?= Mbits/sec)' 我只想显示吞吐量,例如0.32,但因为我在这里使用1K,所以会出现警告,显示会变为 WARNING: TCP window size set to 1024 bytes. A small window size will give poor performance. See the Iperf documentation
iperf -c 10.0.0.1 -t 2 -f m -w 1K | grep -Po '[0-9.]*(?= Mbits/sec)'
我只想显示吞吐量,例如0.32,但因为我在这里使用1K,所以会出现警告,显示会变为
WARNING: TCP window size set to 1024 bytes. A small window size will give poor performance. See the Iperf documentation.
0.32
如何删除此警告,以便我只能获得“0.32”?只需将警告消息发送到
/dev/null
,然后您只能获得输出
所以你的命令是
iperf -c 10.0.0.1 -t 2 -f m -w 1K 2> /dev/null | grep -Po '[0-9.]*(?= Mbits/sec)'
在这里发送到/dev/null是什么意思?如何通过bash脚本发送?
command 2>/dev/null
,这将删除警告表并仅打印输出。我使用的是这样的:iperf-c 10.0.0.1-t 2-f m-w 1K 2>/dev/null | grep-Po'[0-9.]*(?=Mbits/sec),它可以工作。感谢you@user2290560是的,您必须在iperf
命令中使用它,因为该命令本身只生成警告消息。