Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a access log file on the webserver. the log contains info on userids , date/time and page acccessed.
I need help with a shell scipt that can parse the file and compile a consilidated list of userids, and page accessed by time.Here's an example of 2 records fom the file.
182.178.112.13 - - [23/May/2002:07:39:01 -0400] "GET /mai-cgi/Home.cgi?userid=114736 HTTP/1.0" 200 12098
182.178.112.13 - - [23/May/2002:07:39:01 -0400] "GET /mai-cgi/TopMenuBar4HomePage.cgi?userid=114736 HTTP/1.0" 200 1413Thanks in advance.

This is a job for awk, I am not going to
write you all the code: the date
reformatting would take a separate function
in any case to arrange the data ordinally.A brief, untested, partial idea is this::
awk '
/\[.*:[0-9]+:[0-9]+[0-9]+-.*\]/ {
sub(/[.*:/,"",$0)
sub(/-.*\]/,"",$0)
dates[cnt++","NR] = $0
}/\?userid=[0-9]+/ {
userids[ucnt++","NR] = $0
}/\/[a-z]+-[a-z]\/[A-Za-z]+.cgi/ {
pages[pcnt++",",NR] = $0
}Which gathers your data into three separate
arrays and is now ready for you to sort and
recalculate the data.see if someone on comp.lang.awk wants to
write your program for you.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |