打印一行中的比特率和信号电平

时间:2013-07-01 01:38:22

标签: iwconfig

我想在一行中打印出iwconfig的比特率和信号电平,并用空格分开。到目前为止,我使用不同的命令分别打印比特率和信号强度:

  

iwconfig wlan0 | awk -F'[=] +''/比特率/ {打印$ 4}'

     

iwconfig wlan0 | awk -F'[=] +''/信号电平/ {打印$ 7}'

,结果将是

  

54

     

-43

是否有可能让它们像这样:

  

54 -43

我该怎么办?谢谢

1 个答案:

答案 0 :(得分:0)

One simple way is to assign the output of your commands
to variables.  That way, you can print them out however you want.
I just tested this on Ubuntu 12.4.  Note the back quotes around
the commands.

v1=`iwconfig wlan0 | awk -F'[ =]+' '/Bit Rate/ {print $4}'`

v2=`iwconfig wlan0 | awk -F'[ =]+' '/Signal level/ {print $7}'`

echo $v1 $v2