帮忙看下哦
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
network="192.168.1" #
for sitenu in $(seq 1 100) #
do
#
ping -c 1 -w 1 ${network}.${sitenu} &> /dev/null && result=0 || result=1
#
if [ "$result" == 0 ]; then
echo "Server ${network}.${sitenu} is UP."
else
echo "Server ${network}.${sitenu} is DOWN."
fi
done
这段代码
请帮我解释下
ping -c 1 -w 1 ${network}.${sitenu} &> /dev/null && result=0 || result=1
中“ &> /dev/null &&” 是什么意思哦?
------解决方案--------------------
ping -c 1 -w 1 ${network}.${sitenu} &> /dev/null && result=0 || result=1
你分解命令有问题 &>是把stdout stderr 的输出都写入/dev/null (扔掉) && 是并且的意思