Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Jul 2003 17:55:36 -0700 (PDT)
From:      Thomas McIntyre <temac@yahoo.com>
To:        hawkeyd@visi.com
Cc:        listone@deathbeforedecaf.net
Subject:   Re: sed(1) regular expression gurus
Message-ID:  <20030715005536.45555.qmail@web14202.mail.yahoo.com>

next in thread | raw e-mail | index | archive | help
Dave wrote:

> 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

I know you want to avoid perl, but this kind of problem is it's
sweet spot.  The following might be incrementally better (though the
expression to recognize a dotted quad is technically incorrect):

perl -ne '
    next unless /^by/; 
    @f=(split)[1..2]; 
    $_=pop @f; 
    s/^\D*//g; 
    s/\D*$//g; 
    push(@f,$_) if /^(\d{1,3}\.){3}(\d{1,3})$/; 
    print join(" ", @f)."\n";
'

I'm not fluent enough to translate it but I think awk has all the
required features to do so.

Tom McIntyre


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030715005536.45555.qmail>