How to grep for IP addresses using the GNU egrep utility

This is an useful regular expression if you're looking for IP addresses:

egrep '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}'

Related:
How to sort IP addresses using the GNU sort utility

Topic:

Comments

With the current egrep expression, wrong IP addresses with alphanumeric characters in the last byte such as 192.168.1.3Z will match. To solve this problem out, you have to add $ at end of egrep expression, i.e: egrep '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}$'

Cheers.