From owner-freebsd-questions@FreeBSD.ORG Mon Jul 14 20:19:37 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C173D37B401 for ; Mon, 14 Jul 2003 20:19:36 -0700 (PDT) Received: from zim.0x7e.net (zim.0x7e.net [203.38.184.132]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F5D143F93 for ; Mon, 14 Jul 2003 20:19:35 -0700 (PDT) (envelope-from listone@deathbeforedecaf.net) Received: from goo.0x7e.net ([203.38.184.164] helo=goo) by zim.0x7e.net with smtp (Exim 3.36 #1) id 19cGLf-0003Ct-00; Tue, 15 Jul 2003 12:49:27 +0930 Message-ID: <00ef01c34a7f$e5afedc0$a4b826cb@goo> From: "Rob" To: References: <20030714140816.GA27439@sheol.localdomain><00b001c34a1b$4ad17800$a4b826cb@goo> <20030714160454.GA28042@sheol.localdomain> Date: Tue, 15 Jul 2003 12:33:38 +0930 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4927.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 cc: questions at FreeBSD Subject: Re: sed(1) regular expression gurus X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jul 2003 03:19:37 -0000 Probably because I'm using FS to throw away all non-hostname characters - by the time it gets to the sendmail version, there's nothing to distinguish one group of 4 numbers from another. The 'one or more' is for lines like this by some.host.at.another.com ([123.4.56.789]) id 3A4E07B03 ^ ^^^ ^^^ ^ where the hostnames (or IPs) are separated by multiple characters. As you've discovered, this isn't necessarily the best approach.... ----- Original Message ----- From: "D J Hawkey Jr" Subject: Re: sed(1) regular expression gurus > On Jul 15, at 12:49 AM, Rob wrote: > > > > awk --posix -F'[^0-9A-Za-z.]+' ' > > $1 ~ /by/ { result = $2 > > for (i=3; i<=NF; i++) { > > if ($i ~ /^([0-9]+\.){3}[0-9]+$/) { > > result = result " " $i > > } > > } > > print result > > }' > > > > There may be 'neater' ways of doing it, but it's the most concise > > example I could come up with. > > This is better than anything I've dreamed up with sed or awk, and is > really close, but it fails on this: > > by nospam.mc.mpls.visi.com (8.11.6/8.11.6.2) with ESMTP id 3A4E07B03 > > The parenthetical is a [hacked] sendmail version. I don't see how the > script fails, though, as you do test for a full/complete "dotted quad", > and even test for a BOL and EOL on either side it. The "8.11.6" shouldn't > match. I changed the '+'es to "{1,3}"s for even better precision in the > "if (...)", but it didn't make any difference (nor should it have). > > BTW, why the "one or more" flag in the FS assignment? > > > You need to include the --posix option to get the '{3}' notation to work > > (peculiar to GNU awk). > > Kinda throws portability out the window, but I'll settle for it. > > Dave > > -- > ______________________ ______________________ > \__________________ \ D. J. HAWKEY JR. / __________________/ > \________________/\ hawkeyd@visi.com /\________________/ > http://www.visi.com/~hawkeyd/ > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >