Skip to content

Instantly share code, notes, and snippets.

@michaelcoyote

michaelcoyote/grepip.sh

Last active Aug 29, 2015
Embed
What would you like to do?
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