regex help needed

Bennett Todd bet at
Thu Oct 14 19:13:43 PDT 2004

2004-10-14T23:10:01 John Galbrit:
> How would I grep logfiles to search for all IP addresses?

There are _lots_ of answers. Here's mine:

grep '[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*' filename

That's not as precise as it could possibly be, but the
false-positives (strings of digits that are greater than 255,
various invalid IP blocks, etc) are relatively rare, and dodging
them makes the expression a _lot_ trickier.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <>

More information about the lfs-chat mailing list