From owner-freebsd-questions@FreeBSD.ORG Tue Jan 3 21:03:04 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org 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 EFFAC16A41F for ; Tue, 3 Jan 2006 21:03:04 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from rosebud.otenet.gr (rosebud.otenet.gr [195.170.0.94]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8667443D5E for ; Tue, 3 Jan 2006 21:03:02 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from flame.pc (patr530-a109.otenet.gr [212.205.215.109]) by rosebud.otenet.gr (8.13.4/8.13.4/Debian-8) with ESMTP id k03L2rpV003504; Tue, 3 Jan 2006 23:02:55 +0200 Received: by flame.pc (Postfix, from userid 1001) id 95D79116C5; Tue, 3 Jan 2006 23:01:35 +0200 (EET) Date: Tue, 3 Jan 2006 23:01:35 +0200 From: Giorgos Keramidas To: doug@polands.org Message-ID: <20060103210135.GA1171@flame.pc> References: <06fe145ebc265841b4c499f5dc1e72ab@athensasd.org> <20051109180353.GA10584@flame.pc> <20051109184814.GA57162@flame.pc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Cc: Bart Silverstrim , freebsd-questions@freebsd.org Subject: Re: log file conversion (OT?) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jan 2006 21:03:05 -0000 On 2006-01-03 14:05, Doug Poland 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 :)