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
776 M2 Mac fails to install rbenv install 3.1.3 due to errors
771 GDB gets version error when attempting to debug with the Presense SDK (IDE)
856 Uncaught (inpromise) Error on Electron: An object could not be cloned
1235 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2025 OneMinuteCode. All rights reserved.