in reply to search for a string and return previous relating string if found

Sounds fairly straightforward. What did you try and in what way did it fail?

  • Comment on Re: search for a string and return previous relating string if found

Replies are listed 'Best First'.
Re^2: search for a string and return previous relating string if found
by Anonymous Monk on Dec 06, 2017 at 18:15 UTC

    you caught me out ;-] if have been using powershell select-string, but am having issues with it searching between the !! delimeters in the text files. using a context produces the lines above or below the match, but this is always variable as the code is different on each section of the input file.

     Select-String -Pattern "" -context 2  *.txt

    I use a basic perl script to search through for single matches but this stuff is beyond my grasp of Perl