tail -f mylog.log | grep some-keyword
It is possible to filter the log by pipe + grep in the same way as above The problem is that this method does not filter the output of many lines, not one line, and everything except the first line is cut.
The first line blah blah
Second line, some-keyword blah blah
Third line related log1
Log related to the fourth line 2
Log 3 related to line 5
Sixth row, blah blah
Seventh line blah blah
Is there a way to filter the second to fifth lines when the log is printed like above?
unix linux terminal shell grep
Assuming that the logs are logged regularly, I think we can take advantage of option -A.
The option to output up to a few lines after that keyword.
tail -f mylog.log | grep -A3 some-keyword
© 2024 OneMinuteCode. All rights reserved.