Command for reloading file from disk to show changes when using “less?”
There are two possibly relevant commands detailed in the fine manual for less(1)
R Repaint the screen, discarding any buffered input. Useful if
the file is changing while it is being viewed.
F Scroll forward, and keep trying to read when the end of file is
reached. Normally this command would be used when already at
the end of the file. It is a way to monitor the tail of a file
which is growing while it is being viewed. (The behavior is
similar to the "tail -f" command.)
R
for repaint does not always reload the file.[1]
A workaround that always reloads the file is to press hq
, which will open the Help page, then quit. It has a side effect of forcing the file to reload.
[1] Here are some examples of situations that R
do and do not reload:
>
and>>
changes: DO get reloadedsed -i
, gEdit, TextEdit: DO NOT get reloaded- On Linux,
vi
changes: DO get reloaded - On Mac,
vi
changes: DO NOT get reloaded
I believe the difference comes down to whether the inode changes (you can check with ls -i foo.txt
). If the inode changes, then R
will not work.