Advertisement
Sergio_Istea

ifs.sh

Oct 19th, 2022
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. ip=$1
  2. # guardamos IFS original
  3. ifs_bak=$IFS
  4.  
  5. # Declaramos un nuevo IFS
  6. IFS=.
  7.  
  8. # almacenamaos cada campo en un array
  9.  
  10. octeto=($ip)
  11.  
  12. # reestablecemos el IFS
  13. IFS=$ifs_bak
  14.  
  15. contador=0
  16.  
  17. if [ ${#octeto[@]} -eq 4 ];then
  18.  
  19.  
  20. for i in ${octeto[@]};do
  21.  
  22. echo $i
  23. done
  24. else
  25. echo "No es una ip valida"
  26.  
  27. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement