Analysis: IP consist of four digits, in the division point, a set of the most up to 3 and each field not be greater than 255 [.]
# / Bin / the bash!
Function checkip () {
if echo $IP|egrep"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then
if [ $VALID_CHECK == "yes" ]; then
echo "IP $IP available!"
return 0
else
echo "IP $IP not available!"
return 1
fi
else
echo "IP format error!"
return 1
fi
}
while true; do
read -p "Please enter IP: " IP
checkip $IP
[ $? -eq 0 ] && break
done