From owner-freebsd-questions@FreeBSD.ORG Wed Nov 9 18:48:18 2005 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 C213E16A41F for ; Wed, 9 Nov 2005 18:48:18 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from mailgate.bytemobile.com (mailgate.bytemobile.com [209.10.233.248]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6FCFF43D69 for ; Wed, 9 Nov 2005 18:48:18 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Date: Wed, 9 Nov 2005 10:48:14 -0800 From: Giorgos Keramidas To: Bart Silverstrim Message-ID: <20051109184814.GA57162@flame.pc> References: <06fe145ebc265841b4c499f5dc1e72ab@athensasd.org> <20051109180353.GA10584@flame.pc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OriginalArrivalTime: 09 Nov 2005 18:48:17.0744 (UTC) FILETIME=[26047500:01C5E55E] Cc: 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: Wed, 09 Nov 2005 18:48:18 -0000 On 2005-11-09 13:44, Bart Silverstrim wrote: > On Nov 9, 2005, at 1:03 PM, Giorgos Keramidas wrote: > >Yes. Perl should work fine here. > > > > $ 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 > > Is there a way to get it to take in each line of the logfile and output > it to a new file? It wouldn't be as easy as a "cat access.log | (perl > code here) >> newfile.log" would it? Of course it would :) This is why I used the -pe option when I wrote the script above, to make sure that Perl acts as a 'filter'. - Giorgos PS: Please, ignore the automatically forced 'footer' below, until I find a way to post messages without crap added automatically by the Exchange relay I'm forced to use these days. ----------------------------------------------------------------- This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail, do not forward this email to any other person, delete this e-mail and destroy all copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal.