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.

1
  • Your explanation for the need of less does not make sense. tail passes control characters without modifications. Jul 12, 2023 at 8:41

3 Answers 3

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
2
  • less +F does not quit when I press q
    – alper
    Dec 25, 2021 at 11:08
  • 2
    You have to press CTRL+C to stop watching the file, then press q
    – varogen
    May 19, 2022 at 21:31
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

1
  • 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. Jul 12, 2023 at 8: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.

1
  • 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 Bot
    Dec 21, 2022 at 21:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .