Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Feb 2002 16:34:06 +0000
From:      Matt H <freebsd-questions@cuntbubble.com>
To:        freebsd-questions@freebsd.org
Subject:   Fw: Re: Re - Sorting Apache logs by Date and Time
Message-ID:  <20020222163406.34b1f9f4.freebsd-questions@cuntbubble.com>

next in thread | raw e-mail | index | archive | help


Begin forwarded message:

Date: Fri, 22 Feb 2002 14:17:22 +0000
From: "Alex Dyas" <alexdyas@hotmail.com>
To: "freebsd-questions@cuntbubble.com" <freebsd-questions@cuntbubble.com>
Subject: Re: Re - Sorting Apache logs by Date and Time


>On Fri, 22 Feb 2002 09:55:42 +0000
>"Alex Dyas" <alexdyas@hotmail.com> wrote:
>
> > sort -k <n> <logfile>
> >
> > where n is the space delimeted field you want to sort on. thus to solve 
>your
> > problem :
> >
> > sort -k 4 access_log
> >
>
>but Dec should be sorted to after Jan
>
>sort knows not about short month abbreviations
>
>as the post said in the first place!
>
>M

bah, that will teach me to read half an email before posting.

ok then :

cat access_log | sed -f sed1.cmd | sort -k 4 | sed2.cmd

where sed1.cmd :

s/Jan/01XXXX/
s/Feb/02XXXX/
s/Mar/03XXXX/
s/Apr/04XXXX/
s/May/05XXXX/
s/Jun/06XXXX/
s/Jul/07XXXX/
s/Aug/08XXXX/
s/Sep/09XXXX/
s/Oct/10XXXX/
s/Nov/11XXXX/
s/Dec/12XXXX/

and sed2.cmd :

s/01XXXX/Jan/
s/02XXXX/Feb/
s/03XXXX/Mar/
s/04XXXX/Apr/
s/05XXXX/May/
s/06XXXX/Jun/
s/07XXXX/Jul/
s/08XXXX/Aug/
s/09XXXX/Sep/
s/10XXXX/Oct/
s/11XXXX/Nov/
s/12XXXX/Dec/

The second sed is not entirely necessary if you don't mind keeping your 
"Jan"s as "01"s etc in the final file. Also you may want to tighten up the 
regexpressions a little more so you don't go changing Jan somewhere else in 
the log line.

a little more useful than the first post i hope.

alex...

"Mr. Watson. Come here. I need you."


-- 
---------------------------------------------------------------------------
Disclaimer:
By sending an email to ANY of my addresses you are agreeing that: 

- I am by definition, "the intended recipient" 
- All information in the email is mine to do with as I see fit and make
  such financial profit, political mileage, or good joke as it lends
  itself to. In particular, I may quote it on usenet. 
- I may take the contents as representing the views of your company. 
- This overrides any disclaimer or statement of confidentiality that may
  be included on your message.
---------------------------------------------------------------------------

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?20020222163406.34b1f9f4.freebsd-questions>