I have a file
[me@server hi]$ cat ip12
11.22.33.44
192.68.1.2
helo
l
72.34.34.200
333.444.555.666
12.23e.544.423
myip1 11.22.33.44
myip2 33.44.55.66 #fine this IP should also be listed
I do
[me@server hi]$ cat ip12 | grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$'
11.22.33.44
192.68.1.2
72.34.34.200
333.444.555.666
I get results of IP address, but I need here 11.22.33.44 ad 33.44.55.66 also listed.
---------- Post updated at 03:18 AM ---------- Previous update was at 03:15 AM ----------
Nevermind I got it
[me@server me]$ cat ip12 | grep -E -o '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
11.22.33.44
192.68.1.2
72.34.34.200
11.22.33.44
33.44.55.66