for循环检查linux中IP是否被占用

for循环检查linux中IP是否被占用:

for i in 192.168.80.{60..80}
do
    ping -c 2 -W 1 $i &> /dev/null
       if [ "$?" = "0" ];then
            echo $i "已被占用"
       else
            echo $i "空闲"
       fi
done

你可能感兴趣的:(linux,linux,IP占用检查,shell脚本for循环示例)