in reply to Extracting Pattern Match from log

...foolish mortal Perl Monks ... ;) If you like sed, here's a way to do it, for TIMTOWTDI:

$ sed -n 's/^.*450 <\([^>]*\)>.*$/\1/p' /var/log/mail/info

Not that it's faster, but it's different :)

--
b10m

All code is usually tested, but rarely trusted.

Replies are listed 'Best First'.
Re: Re: Extracting Pattern Match from log
by Fletch (Bishop) on Jan 28, 2004 at 14:43 UTC

    Wow, definately not faster here (dual p4 box, RedHat 9).

    sed -n 's/^.*450: <\([^>]*\)>.*$/\1/p' bar > /dev/null 57.37s user 0.08s system 99% cpu 58.002 total perl -lne 'print $1 if /450: <([^>]+)/' bar > /dev/null 6.95s user 0.09s system 98% cpu 7.164 total ruby -ne 'puts $1 if /450: <([^>]+)/' bar > /dev/null 10.46s user 0.09s system 96% cpu 10.939 total tarsier:~ 602> wc -l bar ; head -4 bar 2430000 bar blah de bla 450: <zorch@example.com> woop blah de bla 450: <blink@example.com> woop blah de bla 450: <zorch@example.com> woop blah de bla 450: <blink@example.com> woop