VeeamON 2021: Free Online Conference - Register Now VeeamON 2021: Free Online Conference - Register Now

Looking for a script to parse/extract text from log files

Home Forums Scripting General Scripting Looking for a script to parse/extract text from log files

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    Add2Kart
    Member
    #162868

    Being something of a novice, I know enough to draw a single line of text from an ascii file but I would like to capture selected text from multiple lines if possible. Well, needless to say, I’m having a time doing it and here is my situation.

    I would like to search through a folder of log files (usually 1000 or more) and find any line within a log file that has the text ‘ERROR:’ (see below). I would then capture most of that line and then a portion of the text in the line just above it, outputting this yet into a second text file.

    ExampleLogFile.txt
    ………………………………………………………
    10/10/2010 10:10:01 AM Uploading Document: ABCD_123456789P001234567
    10/10/2010 10:11:18 AM ERROR: The underlying connection was closed: The connection was closed unexpectedly.
    ………………………………………………………

    Text to be captured from second line (Date, Time, Complete error message)

    Text to be captured from line above (last 24 characters): ABCD_123456789P001234567

    ExampleOutputFile.txt
    ………………………………………………………
    10/10/2010 10:11:18 AM ABCD_123456789P001234567 The underlying connection was closed: The connection was closed unexpectedly.
    ………………………………………………………

    Is this even feasible? Any ideas are very welcome!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Free Online Conference - May 25th and 26th

VeeamON 2021: Free Online Conference

Join us to gain your professional edge with technical and visionary learning from the brightest minds in IT at the definitive conference for Modern Data Protection.

Register Now

Sponsored By