Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Script to find IP addresses

 
Highlighted
Regular Advisor

Script to find IP addresses

How would I find any IPv4 addresses in any file under, e.g. /var/opt/lib/* ?
1 REPLY 1
Highlighted
Honored Contributor

Re: Script to find IP addresses

Did you try google? for example for 'find ip address string"

http://www.regular-expressions.info/examples.html

Many ways...


You could use grep to look for a 3 sequences of up to 3 numbers followed period. Add an extra [0-9] to be extra sure.


# grep "\([0-9]\{1,3\}\.\)\{3\}[0-9]" *



In perl I would probably just write : /\d+\.\d+\.\d+\.\d+/

fwiw,
Hein