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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
06-13-2012, 11:39 PM
|
#1
|
LQ Newbie
Registered: Jun 2012
Posts: 5
Rep:
|
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.
|
|
|
06-13-2012, 11:48 PM
|
#2
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,419
|
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.
|
06-25-2012, 07:56 PM
|
#3
|
LQ Newbie
Registered: Jun 2012
Posts: 5
Original Poster
Rep:
|
How to implement search in python
Quote:
Originally Posted by chrism01
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
|
|
|
All times are GMT -5. The time now is 08:39 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|