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?
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 uses
xterm -geometry 60x6 -e bash -c 'while true; do dat=$(date "+%H:%M:%S");echo "Hello $dat";echo "world $dat";echo "alias $dat";echo "blank $dat";echo " $dat"; sleep 1;done'|tail -f
You should be able to replace the while loop with your program, that prints lines every second