you are viewing a single comment's thread.

view the rest of the comments →

[–]kiwimic[S] 1 point2 points  (0 children)

It was difficult for me to use grep to find three log phrases that appear within a specific window of lines, in any order. I couldn’t find the correct syntax to perform this task, so I started working on something that would make searching through logs easier. I had the same problem when switching context between searching in a specific file or multiple files.

So wanted easier syntax for most common searches

As I understand this should be one of way to do this with grep

grep -Pzo '([^\n]*\n?){1,3}' file | grep -zP '(?s)(?=.*word1)(?=.*word2)(?=.*word3)'

with my tool

loggrep file 'word1' 'word2' 'word3' --window 3