LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 06-13-2012, 10:39 PM   #1
shwhooda
LQ Newbie
 
Registered: Jun 2012
Posts: 5

Rep: Reputation: Disabled
how to select date and some specific data from a log file


Hi,
I am new to Linux. I have to search a log file and extract the date and "UPDATE_STOP" data to a csv file in 2 columns.
This is the sample from my log file :

RTS_WS974 05/06/12 01:04:28.801 [20:23:38.450] recv :4620
RTS_WS974 05/06/12 01:04:30.863 [20:23:41.450] MethodName : UPDATE_STOP

So my requirement is :
>> Output CSV File
Column A Column B
05/06/12 01:04:30.863 MethodName : UPDATE_STOP

There is other data in the file which i dont need.
Please help me in getting the output. I tried grep command however, i am able to extract the only the method but not sure how to extract the varying time.
 
Old 06-13-2012, 10:48 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
Here's a very simple method
Code:
grep UPDATE_STOP logfile|awk '{print  $2,$3,$5,$6,$7}'

# if you actually want a comma eg before Method..
grep UPDATE_STOP logfile|awk '{print  $2,$3",",$5,$6,$7}'
http://www.grymoire.com/Unix/Awk.html
 
1 members found this post helpful.
Old 06-25-2012, 06:56 PM   #3
shwhooda
LQ Newbie
 
Registered: Jun 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
How to implement search in python

Quote:
Originally Posted by chrism01 View Post
Here's a very simple method
Code:
grep UPDATE_STOP logfile|awk '{print  $2,$3,$5,$6,$7}'

# if you actually want a comma eg before Method..
grep UPDATE_STOP logfile|awk '{print  $2,$3",",$5,$6,$7}'
http://www.grymoire.com/Unix/Awk.html
Hi,
Please let me know how to this can be processed using python.
I tried using read file function and printing line when it finds "UPDATE_STOP" but nothing gets printed.
Best Regards,
Shweta
 
  


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
Tomcat log file in date format imoncloud Linux - General 1 09-16-2011 12:00 PM
Adding date and time to a log file ltodd2 Linux - General 2 12-17-2008 10:05 AM
Log File Date Oddness iamryman Linux - Server 1 05-22-2007 01:39 AM
Date in Log file name Runningonair Linux - General 8 06-02-2006 09:45 AM
Deleting data from file by date? mephitic Linux - Newbie 3 09-22-2004 12:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:17 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
Open Source Consulting | Domain Registration