From owner-freebsd-questions Thu Feb 21 11:57:57 2002 Delivered-To: freebsd-questions@freebsd.org Received: from goose.prod.itd.earthlink.net (goose.mail.pas.earthlink.net [207.217.120.18]) by hub.freebsd.org (Postfix) with ESMTP id 8FCE737B402 for ; Thu, 21 Feb 2002 11:57:53 -0800 (PST) Received: from sdn-ar-003dcwashp004.dialsprint.net ([206.133.21.12] helo=moo.holy.cow) by goose.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16dzLk-0000aP-00; Thu, 21 Feb 2002 11:57:53 -0800 Received: by moo.holy.cow (Postfix, from userid 1001) id 61E6D50B87; Thu, 21 Feb 2002 15:00:02 -0500 (EST) Date: Thu, 21 Feb 2002 15:00:02 -0500 From: parv To: Scott Aitken Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Sorting Apache logs by Date and Time Message-ID: <20020221200002.GB7440@moo.holy.cow> Mail-Followup-To: Scott Aitken , freebsd-questions@FreeBSD.ORG References: <20020222050939.A43475@gandalf.scott.sh> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020222050939.A43475@gandalf.scott.sh> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG in message <20020222050939.A43475@gandalf.scott.sh>, wrote Scott Aitken thusly... > > Hi All, > is there a quick way to sort apache logs by the date and time field if the format is the following: > > 146.101.149.65 - - [22/Feb/2002:04:18:54 +1100] "GET /images/test.png HTTP/1.0" 200 381 ... > > This is a sample line. tooting my horn, look at this... http://www103.pair.com/parv/comp/unix/bin/goodlog ...above is a sh/awk script. note the "BEGIN" block where month array is created to map the month name to number later in the action block. date given in above format is changed to "yyyy.mm.dd hh.mm TZ". also note where i had specified the regex before the action block... ! /w3c_validator.*libwww-perl|\.css|robots\.txt/ ...change/remove as you desire. to explicitly sort the results from this script, pass them to sort (untested)... # goodlog | sort -bdf -t '.' -n -k 2 -n -k 3 -n -k 4 -n -k 5 - parv -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message