Sunday, March 1, 2015

Extract List of IP Addresses from a File using grep

I have run into multiple occurrences where I only want to see the IP Addresses in a given file.  Today I found with the help of Command Line Fu a quick way to parse a file and only return the unique IP Addresses found:

cat tmp.txt | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | sort | uniq

Sometimes I will use this to quickly parse out IP Addresses in an email.  The regulary expression can be changed to extract domain names out of an email also.


No comments:

Post a Comment

Docker - Quick Notes and How To

For an ethical hacking class that I will be teaching coming up in the near future I wanted to identify a way where I could provide students ...