92

I would like to open up a file using less, and have it automatically scroll the file similar to tail -f.

I know that I can do less file, and then hit Shift-F to forward forever; like tail -f.

I need less because it provides the --raw-control-chars flag, which is necessary because my input is colorful.

Evgeny
  • 5,476
Stefan Lasiewski
  • 19,754
  • 24
  • 70
  • 85

3 Answers3

105

use the command "F" while inside of less.

less mylogfile.txt
F

or, to do so automatically, use the +cmd option:

less +F mylogfile.txt
gabe.
  • 11,784
18

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

Evgeny
  • 5,476
  • Unfortunately it is not a complete equivalent: 1. it fails if the file does not exist at the time less is started. 2. less frequently crashes when the content of the file is replaced. – pabouk - Ukraine stay strong Jul 12 '23 at 08:37
-1

Both of those 2 options have the pro/con, for the more detail explanation, pls refer to the blog: https://www.brianstorti.com/stop-using-tail/ ; the author explained it fairly well.

Simply put:

  • tail -F *.txt uses for reading multiple files is better than less +F *.txt.

In contrast, using less +F error_log.txt (using Ctrl-C & F to unload/load the new data) is better than tail -F error_log.txt for reading 1 file only.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. – Community Dec 21 '22 at 21:29