validate_IP(){
if [[ $1 =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]
then
for NUM in `sed 's/\./ /g' <<< $1`
do
if [ $NUM -ge 0 ] && [ $NUM -le 255 ] && [[ ! $NUM =~ ^0[0-9]{1,2}$ ]]
then
continue
else
echo "Invalid"
return 1
fi
done
echo "Valid"
return 0
else
echo "Invalid"
return 1
fi
}
if [[ $1 =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]
then
for NUM in `sed 's/\./ /g' <<< $1`
do
if [ $NUM -ge 0 ] && [ $NUM -le 255 ] && [[ ! $NUM =~ ^0[0-9]{1,2}$ ]]
then
continue
else
echo "Invalid"
return 1
fi
done
echo "Valid"
return 0
else
echo "Invalid"
return 1
fi
}
댓글 없음:
댓글 쓰기