LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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-27-2013, 04:03 PM   #1
andre3050
LQ Newbie
 
Registered: Jun 2013
Posts: 14

Rep: Reputation: Disabled
shell script to strip data from a log file


Hey guys

My first time on this Linux forum. I'm not really new to Linux but unfortunately not had much pratcise.

Is there a script that I can taylor to pick out certain data from a file and write it to a new file? For example, copy any occurrence of a certain error or keyword to a certain keyword then dump it into a file?

You help would be much appreciated-

Thanks
Andre
 
Old 06-27-2013, 06:52 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Well without examples, my first thought would be to redirect grep into a file:
Code:
grep 'what your looking for' /path/to/log_file > file_containing_found_data
 
1 members found this post helpful.
Old 06-27-2013, 09:15 PM   #3
buttugly
Member
 
Registered: Feb 2006
Distribution: distrohopper
Posts: 58

Rep: Reputation: 16
I'm not exactly sure what your trying accomplish, towards that end, try this and see if it gets you closer.

open a terminal
cd into a directory(folder)that you can test in
type dmesg | grep ACPI >acpi.txt

What has happened is we have scanned the dmesg log for any ACPI lines and written them into acpi.txt.

From there you can open with your favorite editor or just type cat acpi.txt to see whats in there.

There are lots of tools, awk, sed come to mind that may do more of what you need.

If you could explain in a bit more detail please?
 
Old 06-27-2013, 09:44 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
You can find this information everywhere on the internet and this site. Grail has already pointed out a great way to do this,.. if that doesn't suit your needs, it will really benefit you to check out the bash scripting tutorials, and searching LQ for similar questions!

Good luck.
 
Old 06-28-2013, 01:19 AM   #6
andre3050
LQ Newbie
 
Registered: Jun 2013
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thanks for the tips.

I'm trying to pick out email addresses from the mail server log that have delivery failures like ones hat have been bounced by the remote server so that I see reasons.

Thanks
Andre
 
Old 06-28-2013, 01:28 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
In that case maybe don't go for re-inventing the wheel but save yourself time and effort and instead have a look at the reporting tools that come with your MTA, any reporting add-ons or Logwatch?
 
Old 06-28-2013, 01:36 AM   #8
andre3050
LQ Newbie
 
Registered: Jun 2013
Posts: 14

Original Poster
Rep: Reputation: Disabled
I don't know. The mail server is Linux/Postfix, but will check
 
  


Reply



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
Perl script for finding useful data in a log file ananthms Programming 2 10-12-2012 05:46 AM
Shell script to monitor the log file & kill the process if log is not updating. milu_k Programming 5 07-19-2012 08:23 AM
[SOLVED] How to create log file in shell script ramecare Linux - Server 12 05-07-2011 07:54 AM
shell script to monitor log file calipryss Linux - Newbie 14 08-05-2008 10:46 PM
Log all of a shell script's I/O to the console and a file trevelluk Programming 8 04-18-2005 01:40 PM

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

All times are GMT -5. The time now is 09:53 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