Results 1 to 5 of 5
Looking for help trying to accomplish writing a script to accomplish the following.
Go to a specified directory and open a log file and parse out specific information and dump ...
- 04-29-2011 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 2
Writing A Script To Parse Information From A Text File
Looking for help trying to accomplish writing a script to accomplish the following.
Go to a specified directory and open a log file and parse out specific information and dump it into another text file.
Can anyone point me in the right direction?
- 04-29-2011 #2Just Joined!
- Join Date
- Apr 2011
- Posts
- 5
Something like:
perhaps?Code:grep "specific information" /path/to/logfile > another/text/file
- 04-29-2011 #3
That depends a lot on what the information is that you're looking for. If you're looking for something like "Every line that contains the word 'hello'", then grep is indeed the easiest and best way, as heliumhe says.
If, however, you want the third column of any line where the first column is a word that is present in some other file, things get more complicated. At this point, you should look into scripting languages (Bash is a simple one, and Perl, Ruby, and Python are all more advanced and complex), and some shell utilities like grep, sed, awk, and cut.
Good luck. If you have more information, or a more specific question, feel free to post.DISTRO=Arch
Registered Linux User #388732
- 04-30-2011 #4Just Joined!
- Join Date
- Mar 2011
- Posts
- 2
Both responses, SUPER Helpful thanks!
The grep worked for what I was trying to do.
Can either of you recommend how I would accomplish automating this to run say once a day?
Thanks in advance!
- 04-30-2011 #5
Use cron for scheduling.
But you might also want to have a look at
man logwatchYou must always face the curtain with a bow.


Reply With Quote