如何在一行上获得输出“echo”和“macaddress”?
这就是我得到的:
ipRange="192.168.0."
macaddress= arp | grep -w "$ipRange$1" | awk '{print $3,$1}'
ping -c1 "$ipRange$1" > /dev/null
if [ $? -eq 0 ]; then
echo "deze host met mac address en ip address is up $macaddress"
else
echo "het is down"
fi
这是输出:
VirtualBox ~ $ bash test2.sh 149
e0:b9:a5:f8:24:c3 192.168.0.149
deze host met mac address en ip address is up
最佳答案
只需替换macaddress= arp | grep -w "$ipRange$1" | awk '{print $3,$1}'
与macaddress=$(arp | grep -w "$ipRange$1" | awk '{print $3,$1}')
关于linux - 如何将echo语句和arp语句的输出放在一行上?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30830715/