Can less follow (by pressing F) a piped input (similarly to a file)?
For a file that is being written to, the command
less <file>
will follow the file when pressing F.
But if I have a command that pipes output directly into less, like this
command | less
pressing F will do nothing.
So it looks like pipes cannot be followed like files can? Or maybe it has to do with command also writing to STDERR? The effect I'm trying to achieve is always see the latest output of the command: just like keeping PageDown pressed!
A related remark holds for G (go to end): when piping directly to less, it won't work.
Best Answer
Pressing F or G makes
less
try to reach input EOF. If the input is a pipe,less
hangs until the pipe is closed on the other side (and not "does nothing").This can be worked around by saving the command output to a temporary file in the background, and then by using it as input for
less
:There is no option to do this in
less
only; however, I admit it would be useful.