Stop using tail -f (mostly)
Posted by jpluimers on 2022/11/07
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-cto go to “normal”lessmode (as if you had opened the file without the+Fflag), and then you have all the normallessfeatures you’d expect, including the search with/foo. You can go to the next or previous occurrence withnorN, up and down withjandk, create marks withmand do all sort of things thatless(1)says you can do.Once you are done, just hit
Fto go back to watching mode again. It’s that easy.- When you need to watch multiple files at the same time,
tail -fcan 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
lessequivalent:less +F --follow-name
–jeroen






Leave a comment