LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-21-2003, 02:31 PM   #1
b_vasu
LQ Newbie
 
Registered: May 2003
Posts: 12

Rep: Reputation: 0
Shell Scripting Question


Hello,
I am new to shell scripting , and here is what I want to do, I need to parse a huge log file and create a text file with that months log records.
Example :
Actual log looks like this
07/12/2003 /web/scripts/mms_script
08/13/2003 /web/scripts/mm_scripts
09/12/2003 /web/scripts/mms_script
10/13/2003 /web/scripts/mm_scripts
11/12/2003 /web/scripts/mms_script
11/13/2003 /web/scripts/mm_scripts

If i run the script it should create november.txt with all the lines of november in them.

11/21/2003 /web/scripts/mm_script
11/21/2003 /web/scripts/mms_script

Appreciate your help !!
 
Old 11-21-2003, 03:10 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
What did you try yourself??

cat logfile | grep '^11' > november.txt

$ cat logfile | grep '^11'
11/12/2003 /web/scripts/mms_script
11/13/2003 /web/scripts/mm_scripts

Or, if you want the month found automatically:

$ cat logfile | grep "^`date '+%m'`" > "`date '+%B'`".log

The above samples can be run from the command line. Up to you to script them
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
a shell-scripting question: mrchaos Slackware 3 09-22-2005 12:00 PM
Shell scripting question. dragin33 Linux - General 2 08-11-2004 06:17 PM
Shell Scripting Question Onyx^ Linux - General 5 04-27-2004 11:37 AM
Shell Scripting Question jester_69 Programming 13 11-05-2003 07:55 PM
Shell Scripting Question chrisk5527 Linux - General 12 07-09-2003 04:36 PM


All times are GMT -5. The time now is 05:49 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration