Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ivp4_pattern='/^([0-9]{1,3}.){3}[0-9]{1,3}(/([0-9]|[1-2][0-9]|3[0-2]))?$/igm'
  4. networks=$(ip addr | grep "inet" | awk '{print $2}')
  5.  
  6. while read -r line;
  7. do
  8. echo "$line"
  9. done <<< "$networks"
  10.  
  11. echo "$ivp4_pattern"
  12. echo "$networks" | grep "$ivp4_pattern"
  13.  
  14. [jonathan@localhost ~]$ ./script.sh
  15. 127.0.0.1/8
  16. ::1/128
  17. 172.16.155.128/24
  18. fe80::da84:977a:d654:7716/64
  19. /^([0-9]{1,3}.){3}[0-9]{1,3}(/([0-9]|[1-2][0-9]|3[0-2]))?$/igm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement