For older versions of
less (many distros still do not have v581 or later as default) you can use the F-key ("Follow") on a pipe in
less as if you were performing less on a file directly by using this one-liner (no tmp files):
The problem is that pressing ctrl+c sends a SIGINT to all commands in the pipeline, aborting not only your
less-follow, but your generating command as well. To work around this I usually put the generating command in a subshell and trap SIGINT there. Like this:
(trap '' SIGINT; command) | less
The parenthesis give you a subshell and
trap with empty command
'' is a special invocation that throws away the signal entirely within that subshell, without propagating it to the currently executing command. SIGINT is the ctrl+c signal. Now you can hit ctrl+c and only
less will receive it, letting you use
less on a pipe just like you would on a log-file or other growing file. Once you quit
less (by pressing q) the pipeline is broken and the generating command gets sent a SIGPIPE, which almost always has the same effect as being sent a SIGINT, but the
trap isn't set up to catch it.
Newer versions of
less from v581 and onwards allow you to use ctrl+x in place of ctrl+c to abort the
follow command (F-key).