Date: Sun, 3 Apr 2022 00:29:44 +0200 From: Ralf Mardorf <ralf-mardorf@riseup.net> To: questions@freebsd.org Subject: Re: extracting an IPv4 address from text? Message-ID: <20220403002944.77a06ee9@archlinux> In-Reply-To: <b2982d76-5edd-2cd0-1cae-83709afa6a39@pettijohn-web.com> References: <25160.44484.392802.868667@jerusalem.litteratus.org> <b2982d76-5edd-2cd0-1cae-83709afa6a39@pettijohn-web.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 2 Apr 2022 17:17:26 -0500, Edgar Pettijohn wrote: >If perl is available: > > >$ perl -MRegexp::Common='net' -n -e "print if $_ =~ $RE{net}{IPv4}" >/path/to/logfile In a previous reply I didn't provide the full quote, but here it is: "If you find yourself needing a feature that is very difficult or impossible to do in AWK, I suggest you either use NAWK, or GAWK, or convert your AWK script into PERL using the "a2p" conversion program which comes with PERL." - https://www.grymoire.com/Unix/Awk.html However, all of us are used to shell scripts. I wasn't aware that perl provides the solution the OP is asking for. A solution using a POSIX (portable) shell script would be nice, too.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20220403002944.77a06ee9>