So here is my requirement.
I am tailing a log file and grepping on it.
I want to get some context on every grep result..
But the context should be "till a pattern is matched" and not the number of lines (which is what grep -A/-B/-C offer).
For example
Say here is my log..
[l] is prefixed to every log line. Also there will be prefix of [logTypeA] or [logTypeB]
[l][logTypeA] - Log line 1
[l][logTypeB] - Log line 2
[l][logTypeA] - Log line 3
....
Random data about Log line 3
....
[l][logTypeB] - Log line 4
Now my if my tail command was tail -f log_file.log | grep "[logTypeA]",
I'd get an output of
[l][logTypeA] - Log line 1
[l][logTypeA] - Log line 3
But I need contextual information for my grep result, and that context is NOT some number of lines, but rather till a particular pattern is matched (in this case [l])..
In the example I want my grep result to be
[l][logTypeA] - Log line 1
[l][logTypeA] - Log line 3
....
Random data about Log line 3
....
From here (How to show lines after each grep match until other specific match?), I tried sed command on my tail like
tail -f log_file.log | sed '/\[logTypeA\]/,/\[l\]/p'
But that doesn't seem to work.
Any ideas?