How Can I Extract All The Information Located Between Two Known Values in a Text File, using LogparserRSS

1 reply

Last post Apr 28, 2016 07:52 PM by JeffJohnson

  • How Can I Extract All The Information Located Between Two Known Values in a Text File, using Logp...

    Apr 01, 2016 04:27 PM|hg363|LINK

    Hi I have a text file with lines of text.

    How Can I Extract all the Information Located Between Two Known Values, from this text file, using Logparser

    The first know value is a text line which looks like this

    ________________________________________

     

    And the second known value is a text line which looks like this

     

    Alex Says office in the ECG

     

    Can some one please show me how to do this?

  • Re: How Can I Extract All The Information Located Between Two Known Values in a Text File, using...

    Apr 28, 2016 07:52 PM|JeffJohnson|LINK

    Unfortunately, this isn't something Log Parser can do. Log Parser is designed to repeat a given task across multiple lines. Doing this from powershell would be trivial... example:

    $p=$false; gc foo.txt | foreach-object{ if($_ -eq "Alex Says office in the ECG") {$p = $false;} if($p){ write-host $_;} if($_ -eq "________________________________________") {$p = $true;}}

    note, I assumed you didn't want either line.  if you do, then simply swap the checks.

    All advice is best effort, as is, no warranties, guarantees or promises of correctness. Validate everything before trusting anything.