Is there a way to dynamically refresh the less command?

In less, you can type F to keep reading at the end of a file (like tail -f); you can type :e and a file name to view a different file, but unfortunately, if you enter the name of the current file, less doesn't reload the file. However there's a trick to make it re-read the current file, suggested by sabgenton: type :e and enter the name of a non-existent file; that causes less to display an error message and then reload the current file.

If you're looking for an alternative to watch ls, here are a few:

  • Modern file managers (e.g. Nautilus, Thunar, Konqueror, Dolphin, Finder) refresh views in real time.
  • Emacs doesn't have real-time refresh, but with auto-revert-mode, it will reload the file or directory every 5 seconds (the delay is configurable).
  • Although w3m is primarily a web browser, it makes a passable directory and text file viewer. Press R to reload the (local) URL.

Shift+F will make less similar to tailf. That is, it gets refreshed if more data is appended to the file.


Simply type:

less +F filename

This emulates pressing "F" within the editor.

Tags:

Watch

Less