Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Feb 2002 15:00:02 -0500
From:      parv <parv_@yahoo.com>
To:        Scott Aitken <null0@pobox.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Sorting Apache logs by Date and Time
Message-ID:  <20020221200002.GB7440@moo.holy.cow>
In-Reply-To: <20020222050939.A43475@gandalf.scott.sh>
References:  <20020222050939.A43475@gandalf.scott.sh>

next in thread | previous in thread | raw e-mail | index | archive | help
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




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