Parse log files for data

From: Dan (agent_at_thwackspam.fathom.org)
Date: 07/31/04


Date: Sat, 31 Jul 2004 05:49:11 GMT

I have a bunch of custom log files with database queries in them, and
would like to extract all the insert and update queries so I can
recreate some lost data.

I'm pretty sure this is the perfect exercise for a perl script. I
just don't have the vocabulary to write it myself. But this is all it
needs to do:

* Open, in order, all log files named yyyymmdd.log in the current
directory. (where yyyymmdd is what you think it is)

* For each file, look at each line, and if it begins with " query=
INSERT" or " query = UPDATE", write that entire line starting from the
word "INSERT" or "UPDATE" to the output file.

I'm not sure what version of perl I have or if that matters, but my
system is Fedora Core 2, so whatever comes with that...

Any takers? The 2 minutes of your time would be greatly appreciated.
:)



Relevant Pages

  • Re: Parse log files for data
    ... > I have a bunch of custom log files with database queries in them, ... > would like to extract all the insert and update queries so I can ... > * Open, in order, all log files named yyyymmdd.log in the current ...
    (comp.lang.perl.misc)
  • Re: IISState File Help Needed
    ... Not from the .log files. ... There is from the .dmp files, ... will give you the page names which may tell you what queries are running. ... Basically, it looks like the query was created, a connection ...
    (microsoft.public.inetserver.iis)
  • Multiple programs output to separate log files + to STDOUT
    ... I am calling many "C" programs from my perl script. ... output of each of these "C" programs in DIFFERENT log files as well as ... I want to display this output to STDOUT. ... after one programm execution is completed in PERL script. ...
    (perl.beginners)
  • Re: Yet another date problem, with a twist.
    ... GeffP wrote: ... > Victor Castro wrote: ... >> I'm in a situation where I have thousands of log files which are named by date, ... >> I prefer a shell or perl script but at this point I'm just looking for a ...
    (comp.unix.solaris)
  • Log monitoring script
    ... I have to write a script that monitors the system logfiles for ... certain words and send alerts if it finds one. ... I have a skeleton perl script ... daemon rather than running it via cron every 1 sec so that the log files can ...
    (SunManagers)