Advertisement
andmalv

[Tip] Validar Direccion IP

Aug 17th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.30 KB | None | 0 0
  1. ip=''
  2. if [[ $ip =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then
  3.     ip=$( echo $ip | tr '.' ' ' )
  4.     ip=($ip)
  5.  
  6.     if [[ ${ip[0]} -le 255 && ${ip[1]} -le 255  && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]; then
  7.         echo "Dirección IP valida."
  8.     else
  9.         echo "Dirección IP invalida."
  10.     fi
  11. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement