I am trying to get the IPv4 addresses from a text file using the following command:
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]))' file.txt
.
This will display the valid IP addresses but will also display the valid part from a longer invalid IP which I don't want.
Input example:
IP address one is 192.168.1.1, ip 2 is 192.168.1.2.
192.168.1.3 192.168.1.10.1
Output I get:
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.10
Output I want:
192.168.1.1
192.168.1.2
192.168.1.3