I have a growing log file for which I want to display only the last 15 lines. What i know i can do here

tail -n 15 -F mylogfile.txt

As the log file is filled, tail appends the last lines to the display.

I'm looking for a solution that only displays the last 15 lines and remove the lines before the last 15 after it has been updated Would you like to share your idea?

Best Answer


It might suffice to use watch

$ watch tail -n 15 mylogfile.txt