0

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

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

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

结果将是

54

-43

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

54 -43

我该怎么办?谢谢

4

1 回答 1

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
于 2013-07-01T02:10:51.170 回答