Skip to content

Instantly share code, notes, and snippets.

@michaelcoyote
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelcoyote/1412b2aee0f47d02bf89 to your computer and use it in GitHub Desktop.
Save michaelcoyote/1412b2aee0f47d02bf89 to your computer and use it in GitHub Desktop.
grep for ip address
# 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