Reputation: 69
Is there any way to highlight, i.e. bold, or colorize new added lines since last change?
For example, I am watching a log file with multiple similar errors in PHP error_log (different line or function name, etc)... And I have to look at timestamps where one set of errors ends and another begins (page refresh)
It would be very helpful if there is a way to highlight, but only last added lines.
I am looking for solution to run on macOS and Linux in console.
Upvotes: 1
Views: 2178
Reputation: 2948
Turn on grep
's line buffering mode.
Using tail
tail -f fileName | grep --line-buffered my_pattern
Using less
less +F fileName | grep --line-buffered my_pattern
Using watch & tail to highlight new lines
watch -d tail fileName
Note: For linux based systems.
Upvotes: 2
Reputation: 1642
Check out the watch
command, if your system has it. The command:
watch -d tail /your/file/here
will display the file and highlight the differences character by character. Note that you do not want to use the -f
option in this case.
Ubuntu has it. For OSX, you can can use brew install watch
if you have homebrew
installed or sudo ports install watch
if you use ports
.
Another bonus is that it works for any command that has output that changes over time. We have even used it with ls -l
to watch the progress of backups and file compressions.
Upvotes: 1
Reputation: 1023
"tail" itself does not offer a serious way to do this. But give "multitail" a closer look:
https://www.vanheusden.com/multitail/
And for Mac OSX:
http://macappstore.org/multitail/
Upvotes: 0