#!/bin/bash
#edit by www.jbxue.com
for a in {1..254}
do
if ping -w 1 -c 1 152.55.249.$a | grep "100%" >/dev/null
then
echo "152.55.249.$a is Not reachable"
else
echo "152.55.249.$a is reachable"
fi
done
解释:-w表示时间一秒,-c表示ping1次,如果返回100%,则表示失败输入到then语句,否则输入到else语句。
时间: 2024-11-08 05:57:30