Last active
August 29, 2015 14:13
-
-
Save michaelcoyote/1412b2aee0f47d02bf89 to your computer and use it in GitHub Desktop.
grep for ip address
This file contains hidden or 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
# This is a function so, source me in. | |
# really basic grep function to find IP/netmask octets. | |
function ipgrep() | |
{ | |
# find any pattern from "0.0.0.0" to "259.259.259.259" | |
# TODO fix this so it checks for legal octets (255.255.255.255) (Note: may be some time) | |
grep -o -E '\b(((2[0-5]|1[0-9])|[0-9])?([0-9]){1,2}\.){3}((2[0-5]|1[0-9])|[0-9])?([0-9])\b' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment