Re: [squid-users] timestamp

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Sat, 19 Mar 2005 10:53:49 +0100 (CET)

On Sat, 19 Mar 2005, Ronny wrote:

> Well if I want to know who was where at what time I use perl to convert
> timestamps from epoch to 'human' or unix time ;-)
>
> cat /access.log path | perl -l -a -n -e '$F[0] = scalar localtime $F[0];
> print "@F"'

Here is a shorter version, and which also preserves the millisecond field
and alignment:

perl -pe 's/(\d+)/localtime($1)/e' access.log

   -p loop over the input file(s)

   -e execute following statement

   s/ substitute

   (\d+) pattern matching sequence of digits

   localtime($1)
         substitution. $1 refers to first () in the pattern

   /e substitution is an expression

Regards
Henrik
Received on Sat Mar 19 2005 - 02:53:56 MST

This archive was generated by hypermail pre-2.1.9 : Fri Apr 01 2005 - 12:00:02 MST