Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Jan 2006 23:01:35 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        doug@polands.org
Cc:        Bart Silverstrim <bsilverstrim@athensasd.org>, freebsd-questions@freebsd.org
Subject:   Re: log file conversion (OT?)
Message-ID:  <20060103210135.GA1171@flame.pc>
In-Reply-To: <eae8cb0a0601031205w2327ff48qf5c9d764c5a3112@mail.gmail.com>
References:  <06fe145ebc265841b4c499f5dc1e72ab@athensasd.org> <20051109180353.GA10584@flame.pc> <c3593d564c07405fc09bd0e370319c1b@athensasd.org> <20051109184814.GA57162@flame.pc> <eae8cb0a0601031205w2327ff48qf5c9d764c5a3112@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2006-01-03 14:05, Doug Poland <wisco.disco@gmail.com> wrote:
> I wrote some time ago:
> >    $ echo '1131556815.537    101 172.16.2.153 TCP_HIT/200 35674 GET' | \
> >      perl -MPOSIX=strftime \
> >      -pe 'chomp; @x=split /\./; \
> >           $ts = strftime "%Y-%m-%d %H:%M:%S", (localtime($x[0])); \
> >           $_=$ts.".".join(".",@x[1,$#x])."\n";'
> >    2005-11-09 09:20:15.537    101 172.153 TCP_HIT/200 35674 GET
>
> Thank you, Giorgos, for that excellent Perl one-liner.  There is a
> minor problem in that not all the input fields are output correctly.
> Note the IP address is truncated.   I took the liberty of fixing and
> simplifiing (or, obfuscating, depending on one's point of view)
>
> tail -f /usr/local/squid/logs/access.log | \
>   perl -MPOSIX=strftime -ane \
>   '$F[0] = strftime "%Y-%m-%d %H:%M:%S", (localtime($F[0])); \
>   print join(" ", @F) . "\n";'

You're most welcome, of course :)




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