When using tail -f
to display the last few lines of a file, how can I make it only ever display 5 lies, overwriting previous lines when the file is added to?
When using tail -f
to display the last few lines of a file, how can I make it only ever display 5 lies, overwriting previous lines when the file is added to?
Suppose you want to watch the file "file-to-be-watched", the following may do the trick:
Are you working at a text mode console, or for example via ssh from a desktop environment?
I made a small demo with
date
which usesxterm
.You should be able to replace the while loop with your program, that prints lines every second