Extract IP addresses with grep (BASH)
Simple grep patterns to extract ip addresses
Details
- Language: BASH
Snippet
# IPv4
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'
# IPv6
grep -o -P "([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}"