Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk question

Status
Not open for further replies.

jo90

Programmer
Jun 19, 2002
30
GB
Hi,

How do I use awk to get just Ip addresses from a log file? I can do this to a point, however how go I get just the Ip addresses?

Thanks.
 
Jo90:

It depends on the structure of your log file. How about posting a sample.

Regards,

Ed
 
Ed,

I can get ip addesses using something like,
{ print $6 }, however I wish to pick out entries based on 123.123.123.123 - ie I wish to test for ever line with a 4 dot IP address....

Thanks
Jo
 
The simplest pattern to match is:

^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$

but........ to design the mattern to match ANY IP address spec is extremely difficult. I'd suggest reading Friedl's "Regular Expressions" book on pp. 123-125 vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top