Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

I guess it won't work, because stdin is not seekable. (Realy just a guess).

What you can do is write the output in a file end open that with less.

share|improve this answer
    
I don't get it, why can't less just read from the pipe, while blocking... is the above, the correct answer? –  haelix Jan 13 '12 at 15:51
add comment

From the less man page

[Keyboard] COMMANDS [...]

   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  behav‐
          ior is similar to the "tail -f" command.)

so this should work, and it actually works for me.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.