Grep for IP addresses


Another fun day at work. Today’s fun was attempting to extract some IP addresses from a wonderful log file filled with tildes!

Life made a little easier using the below grep to get out the IP format (192.168.1.1) etc. Pretty useful to know.

Example

Log with Tildes (ahhhhhhhh)

20110906000229~83.223.170.23~

Grep

egrep "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" -o
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s