You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Apolinaras Sinkevicius <ap...@yahoo.com> on 2002/07/19 00:04:13 UTC

"sort" command question

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.


dialup-dialup-63.214.107.155.Dial1.Boston1.Level3.net.dial1.boston1.level3.net
[03/Mar/2002:09:40:39 -0600] "GET
/cleavers/windowsmedia_white.gif HTTP/1.1" 200 1861
"http://www.carmelformusic.com/cleavers/themusic.html"
"Mozilla/4.0 (compatible; MSIE 5.01; Windows 95;
SPINWAY.COM)"



__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: "sort" command question

Posted by "Matus \"fantomas\" Uhlar" <uh...@fantomas.sk>.
-> 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?

do you have the logfile unsorted? how did you get it?

I am usually merging lods from more servers, but I modified LogFormat to log
unix time as first record:

LogFormat "%{%s}t %v %a %>s %B %T %u \"%r\" \"%{Referer}i\" \"%{User-Agent}i\""

then I only need to "sort -mn logfile [logfile]"

-- 
 Matus "fantomas" Uhlar, uhlar@fantomas.sk ; http://www.fantomas.sk/
 Warning: I don't wish to receive spam to this address.
 Varovanie: Nezelam si na tuto adresu dostavat akukolvek reklamnu postu.
 Nothing is fool-proof to a talented fool. 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: "sort" command question

Posted by Gary Turner <kk...@swbell.net>.
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.
>
>
>dialup-dialup-63.214.107.155.Dial1.Boston1.Level3.net.dial1.boston1.level3.net
>[03/Mar/2002:09:40:39 -0600] "GET
>/cleavers/windowsmedia_white.gif HTTP/1.1" 200 1861
>"http://www.carmelformusic.com/cleavers/themusic.html"
>"Mozilla/4.0 (compatible; MSIE 5.01; Windows 95;
>SPINWAY.COM)"

As a general approach, run as root 

#!/bin/bash
# 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
solution.

But out of curiosity, aren't your logs already in chronological order?
--
gt       kk5st@swbell.net
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: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org