Some interesting bits from [WayBack] Stop using tail -f (mostly):
- say you want to watch the file
production.log
:$ less +F production.log Important log information here Waiting for data... (interrupt to abort)
Here you have pretty much the same behaviour you’d get with
tail
.Now let’s say something interesting appears, and you want to search all the occurrences of “foo”. You can just hit
Ctrl-c
to go to “normal”less
mode (as if you had opened the file without the+F
flag), and then you have all the normalless
features you’d expect, including the search with/foo
. You can go to the next or previous occurrence withn
orN
, up and down withj
andk
, create marks withm
and do all sort of things thatless(1)
says you can do.Once you are done, just hit
F
to go back to watching mode again. It’s that easy.- When you need to watch multiple files at the same time,
tail -f
can actually give you a better output.
Related: [WayBack] shell – The ‘less’ command-line equivalent of ‘tail -f’ – Unix & Linux Stack Exchange
I prefer
tail -F
-F – The -F option implies the -f option, but tail will also check to see if the file being followed has been renamed or rotated.
The
less
equivalent:less +F --follow-name
–jeroen