Extract IP addresses with grep



Published: 2017-10-05 09:33:46 +0000
Categories: BASH,

Language

BASH

Description

Simple grep patterns to extract ip addresses

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}"

Keywords

ip, grep, identify, extract, ipv4, ipv6, address,

Latest Posts


Copyright © 2019 Ben Tasker | Sitemap | Privacy Policy
Available at snippets.bentasker.co.uk, yr4pnhounvdybotb.onion and snippets.6zdgh5a5e6zpchdz.onion