how to continuously display a file of its last several lines of contents
I use this function all the time to monitor a log file in another terminal window.
tail -f <filename>
I recommend taking it a step forward to look for particular text in the log. Great if you are only interested in seeing some particular entry being written to the file.
tail -f <filename> | grep <keyword or pattern>
You can use screen
to simulate the expected behaviour:
Run
screen
, press Space.Press Ctrl+a followed by S to split the screen.
Resize the top window by pressing Ctrl+a followed by
:resize 4
.In the prompt in the top window, enter
head -n2 file
.Move to the bottom window by pressing Ctrl+a followed by Tab.
Start a new screen session by pressing Ctrl+a followed by c.
In the new prompt, enter
tail -f file
.