locked
How Can I Extract All The Information Located Between Two Known Values in a Text File, using Logparser RRS feed

  • Question

  • User1504639868 posted

    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?

    Friday, April 1, 2016 4:27 PM

All replies

  • User789035500 posted

    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.

    Thursday, April 28, 2016 7:52 PM