如何在一行上獲得輸出「echo」和「macaddress」? 這是我有:如何在一行放置echo語句和arp語句的輸出?
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
提供所需的樣本輸出/代碼 – Jahid
@Jahid deze主機遇到mac地址en ip地址是up e0:b9:a5:f8:24:c3 192.168.0.149 –
@Jahid或者如果有可能「de host met mac address: e0:b9:a5:f8:24:c3 en ip address:192.168.0.149 is up「 –