Forked from hackingbutlegal/gist:cf4ed2601b7b0fef8157
Last active
January 16, 2016 23:22
-
-
Save snorfsneflin/33bb57dd028346085671 to your computer and use it in GitHub Desktop.
Regex to match on only valid IPs including local and bcast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep -E -o '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' file.txt | |
# match addresses formatted as IP/bits - e.g. 192.168.0.1/24 | |
ip addr sh eth0 | grep -E -o "([0-9]+.){3}[0-9]+/[0-9]+" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment