我想在一行中打印出iwconfig的比特率和信号电平,并用空格分隔。到目前为止,我使用不同的命令来分别打印比特率和信号强度,如下所示:
iwconfig wlan0|awk-F'[=]+''/比特率/{print$4}'
iwconfig wlan0|awk-F'[=]+''/信号电平/{print$7}'
结果将是
54
-43
有可能把它们做成这样吗:
54-43
我该怎么办?感谢
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