Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. function IP_valide()
  2. {
  3. local ip=$1
  4. local stat=1
  5. if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
  6. OIFS=$IFS
  7. IFS='.'
  8. ip=($ip)
  9. IFS=$OIFS
  10. [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
  11. && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
  12. stat=$?
  13. fi
  14. return $stat
  15. }
  16.  
  17.  
  18. fichier="$1"
  19. while read -r line
  20. do
  21. IP_valide $line
  22. if [[ $? -ne 0 ]];then
  23. echo $line
  24. fi
  25. done < "$fichier"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement