shell脚本ip校验

shell脚本ip校验

 1 IP=$1
 2 VALID_CHECK=$(echo $IP|awk -F. '$1<=255&&$2<=255&&$3<=255&&$4<=255{print "yes"}')
 3 echo $VALID_CHECK
 4 
 5 if echo $IP|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then
 6         if [ $VALID_CHECK == "yes" ];then
 7                 echo "$IP available."
 8         else
 9                 echo "$IP not available!"
10         fi
11 
12 else
13         echo "Format error!"
14 fi

 

posted @ 2021-06-03 10:44  Leonardo-li  阅读(176)  评论(0编辑  收藏  举报