I found your question while seeking the same answer for myself.
Disappointed by the accepted answer, I came up with a workaround. It's less than ideal, but it allows me to mark my position in the log I'm following with less
, which is the whole point.
I created a small executable script (I called it marklog
) with the following contents, and put it in my path:
#!/bin/sh
echo >> $1
echo >> $1
echo >> $1
echo `date` ---------------------------------------------------------------------- >> $1
echo >> $1
echo >> $1
Of course, this only works if you have write access to the log file--which could be a deal-breaker in many situations. I've also created this version which I use to write to log files I don't own (but to which I have sudo access):
#!/bin/sh
sudo sh -c "echo >> $1"
sudo sh -c "echo >> $1"
sudo sh -c "echo >> $1"
sudo sh -c "echo `date` ------------------------------------------------------------------------- >> $1"
sudo sh -c "echo >> $1"
sudo sh -c "echo >> $1"
These scripts provide just the sort of visual break I was looking for. There are at least 3 ways you can use them:
At the point where you would normally press enter a few times when using tail -f
, instead run marklog
from another terminal (providing the path to the log file as an argument).
Use CtrlZ to suspend less
so you can run the script in the same terminal window, but when you re-foreground less
(using fg
, of course), it will no longer be in 'follow' mode, so you'll need to hit ShiftF again...
Lastly--and this might be the most convenient way, because you don't need to type the path to the log file: Run marklog
directly from less
by typing !marklog %
. Less
will substitute the current filename for %
. However, less
won't respond to the ! while it is in 'follow' mode, so you'll have to hit CtrlC first to exit follow mode, run !marklog %
, then ShiftF again.
With method 3, you also get the added bonus of of Less's command history: Just hit the !
and then use the up-arrow to select the most recent command (for me, it's always marklog
).
Hope this helps someone as much as has already helped me.