输出打印
当我使用以下 echo 语句时,我得到了一个很好的输出,这正是这三个单独的 echo 语句所期望的:
echo AP $macaddr
echo noise floor $noise
echo $channel
输出:
AP ac:67:06:30:eb:00,
noise floor -96
channel=1
但是当我将所有三个语句更改为一个“echo”语句(如下所示)时,输出会中断。
echo AP $macaddr noise floor $noise $channel
输出:
channel=06:30:eb:00, noise floor -96
在此输出中,我没有看到通道,并且 MAC 地址缺少前两个八位位组。 是什么原因造成的?如何避免这种情况呢?
When I use following echo statements I get a nice output which is what expected from such three separate echo statements:
echo AP $macaddr
echo noise floor $noise
echo $channel
Output:
AP ac:67:06:30:eb:00,
noise floor -96
channel=1
But when I change all three into one single 'echo' statement like the following, output breaks.
echo AP $macaddr noise floor $noise $channel
Output:
channel=06:30:eb:00, noise floor -96
In this output I don't see the channel and MAC Address is missing two of its first octets.
What is causing this? How can avoid this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道通道来自哪里,但是 $channel 值的开头或 $noise 结尾处是否有一个虚假的“CR”?
尝试这样做:
……看看这是否会有所不同。如果失败,请查看 $channel 和 $noise (以及任何其他变量)中是否存在任何其他可疑字符:
如果有,请使用 tr -d 将它们从变量中删除。
I don't know where channel comes from, but is there a spurious 'CR' at the start of the value of $channel or end $noise?
Try doing:
...and seeing if that makes a difference. Failing that, see if there's any other dodgy chars in $channel and $noise (and any of the other variables):
and if there are, use
tr -d
to remove them from the variable.$noise
末尾有一个回车符,因此输出'channel=0'
(注意初始空格)会覆盖'AP ac:67: 0'
。You have a carriage return at the end of
$noise
, so the output' channel=0'
(note initial space) is overwriting'AP ac:67:0'
.