shell script match ip address

! # / bin / bash
the Read -p Enter an address: IP

  • [[ "$IP" =~ ^(([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]] && echo it is ok

Guess you like

Origin blog.51cto.com/14240018/2429169