What regular expression can I use to match an IP address?
Fresh3 days ago
Mar 15, 2026152926 viewsConfidence Score0%
0%
Problem
With the following syntax I want to match all IP address in a file (from a script) The problem: It also matches words (IP) that have more then 4 octets: or How can I match a valid IP and only IP addresses with 4 octets? I can also use Perl – a one line syntax solution, if doesn't work.
Error Output
grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' fileUnverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: What regular expression can I use to match an IP address?
Low Risk
try this: which matches all expressions from to with you will get IP addresses only note: on solaris probably egrep will do the job.
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix