Skip to content

REGEX, Extract IP address IPv4

Share Button

Matches IPv4 IP addresses

 

Will display only IP addresses from the file.txt !

grep -o  [0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]* file.txt
grep -o  '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' file.txt
grep -o  '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' file.txt

 

Some Extra….

Will highlight all IP addresses in file.txt

grep --color  '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' file.txt

 

Share Button