Re: extracting an IPv4 address from text?
- In reply to: Robert Huff : "extracting an IPv4 address from text?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 02 Apr 2022 20:41:38 UTC
On Sat, 2 Apr 2022, Robert Huff wrote: > > Hello: > Let's suppose I want to parse a line from auth.log and extract > the IP address (if any) to stdout. > I'm assuming there is a robust way to do this using standard > command-line tools ... but my brain is flailing on the exact method. > Anyone have a example they'd be willing to share? Or is this a > problem already solved? How about: cat auth.log | tr " " "\n" | grep "\." | grep -v "\[" | grep -v "[a-zA-Z]" or something similar, although I am sure there will be a few strays slip through. Daniel Feenberg