LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > LinuxQuestions.org > LQ Suggestions & Feedback
User Name
Password
LQ Suggestions & Feedback Do you have a suggestion for this site or an idea that will make the site better? This forum is for you.
PLEASE READ THIS FORUM - Information and status updates will also be posted here.

Notices



Closed Thread
 
Search this Thread
Old 06-10-2006, 12:39 PM   #1
froglinux
LQ Newbie
 
Registered: Jun 2006
Posts: 12

Rep: Reputation: 0
Question Pattern match and counting script -->how to write ?


Hi Group,

See the following log file of apache (HTTPD).
I want a script which can calculate the busiest date. This file is long (very long) with the lines below:



60.231.97.192 - - [03/Jan/2005:11:43:27 +1100] "GET"
60.231.97.192 - - [03/Jan/2005:11:43:27 +1100] "GET"
60.231.97.192 - - [03/Jan/2005:11:43:27 +1100] "GET"
60.231.97.196 - - [04/Jan/2005:11:43:27 +1100] "GET"
60.231.97.192 - - [05/Feb/2005:11:43:27 +1100] "GET"
60.231.97.195 - - [05/Feb/2005:11:43:27 +1100] "GET"
60.231.97.194 - - [04/Mar/2005:11:43:27 +1100] "GET"
60.231.97.193 - - [04/Mar/2005:11:43:27 +1100] "GET"
60.231.97.192 - - [06/Feb/2005:11:43:27 +1100] "GET"
60.231.97.192 - - [06/Feb/2005:11:43:27 +1100] "GET"
60.231.97.191 - - [06/Mar/2005:11:43:27 +1100] "GET"
60.231.97.192 - - [06/Mar/2005:11:43:27 +1100] "GET"


I can do it with grep command as below, which works perfectly:

# less access.log |grep -c 03/Jan/2005
03

but with this I need to put the pattern manualli i.e. 03/Jan/2005.

Is there a good way to write this script which will automatically give me a busyiest day of the year. the file has more then 4 yrs access record so its only possible with a good script.

Any thought are welcome.

Frog.
 
Old 06-10-2006, 01:11 PM   #2
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
I think this is definitely the wrong forum (suggestions & feedback) for this post. Plus, don't post the same thread into multiple forums.
 
Old 06-10-2006, 01:12 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
In general, I wouldn't try to use a shell script to do this. However, in perl, it is only a few lines of code to parse an Apache log file. There are other equally suitable languages for the task. An alternative might be to use a ready-made log file analyzer.

--- rod.
 
Old 06-10-2006, 01:14 PM   #4
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
This has been posted twice, I just gave a solution here:
http://www.linuxquestions.org/questi...d.php?t=453461
 
Old 06-11-2006, 07:10 PM   #5
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 10,626

Rep: Reputation: 2658Reputation: 2658Reputation: 2658Reputation: 2658Reputation: 2658Reputation: 2658Reputation: 2658Reputation: 2658Reputation: 2658Reputation: 2658Reputation: 2658
// closed dupe.

--jeremy
 
  


Closed Thread

Tags
count, file, match, pattern, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
printing pattern match and not whole line that matches pattern Avatar33 Programming 13 05-06-2009 07:17 AM
how to use the sed w option to redirect pattern match to file nickleus Linux - General 11 04-18-2006 09:34 AM
perl pattern match question lluciano Programming 4 02-28-2006 06:59 AM
svcadm: Pattern 'apache' doesn't match any instances xpucto Solaris / OpenSolaris 8 02-19-2006 08:30 AM
Procmail: match pattern then pass to shell script essdeeay Linux - Software 1 11-08-2004 03:19 PM


All times are GMT -5. The time now is 07:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration