httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Turner <>
Subject Re: "sort" command question
Date Fri, 19 Jul 2002 02:26:48 GMT
On Thu, 18 Jul 2002 15:04:13 -0700 (PDT), Apolinaras Sinkevicius wrote:

>I need to sort my log file cronologically what do I
>need to enter in command line for SORT on RedHat to
>get the log file sorted?
>Here is a snipet of log file. NOTE: this is custom
>style, not the regular apache log file.
>[03/Mar/2002:09:40:39 -0600] "GET
>/cleavers/windowsmedia_white.gif HTTP/1.1" 200 1861
>"Mozilla/4.0 (compatible; MSIE 5.01; Windows 95;

As a general approach, run as root 

# 7/18/02
# Gary Turner
# test script to move date group to the front of the line
# in an Apache access.log file.

# Second, it sorts by the date group and then saves to a temp file

# Make path and file names right.

cat /var/log/apache/access.log | sed -e 's/\([^\[]*\)\(\[.*\]
\)\(.*$\)/\2\1\3/g' | sort > /tmp/datesort.temp

The above is all one line.
I'm a doofus with regexp's, so someone's bound to have a better

But out of curiosity, aren't your logs already in chronological order?
It ain't so much what you don't know that gets you in trouble---
it's what you do know that ain't so.--unk

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message