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.

This question already has an answer here:

I'm usually inside GNU Screen or tmux, which doesn't give me excellent scrolling functionality. Is there an alternative to tail -f that allows me to quickly scroll up?

A tool that is like most is to less and more.

share|improve this question

marked as duplicate by slm, terdon, jasonwryan, Hauke Laging, Gilles Jul 3 '13 at 22:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4 Answers 4

up vote 4 down vote accepted

You can use less +F to start less in its "forward forever" mode. In this mode, less will behave like tail -f, ignoring the ends of files and providing a steady stream of text.

When you want to scroll, press Ctrlc. To re-enter forward forever mode, press F.

share|improve this answer

Well you can use

tail -f <file> | less

then you can have the best of both worlds!

share|improve this answer
    
That will only work for a little while until the user wants to scroll. Then he will have to stop less from reading from the pipe and restart the programs once he is done scrolling. –  paraxor Jul 4 '13 at 12:05

You can also use

    watch -n 10 cat <file>

man watch:

    watch - execute a program periodically, showing output fullscreen

   SYNOPSIS
   watch  [-dhvt]  [-n  <seconds>]  [--differences[=cumulative]] [--help] [--interval=<seconds>] [--no-title]
   [--version] <command>

   DESCRIPTION
   watch runs command repeatedly, displaying its output (the first screenfull).  This allows you to watch the
   program  output change over time.  By default, the program is run every 2 seconds; use -n or --interval to
   specify a different interval.

   The -d or --differences flag will highlight the differences between successive updates.  The  --cumulative
   option  makes highlighting "sticky", presenting a running display of all positions that have ever changed.

   The -t or --no-title option turns off the header showing the interval, command, and current  time  at  the
   top of the display, as well as the following blank line.
share|improve this answer
    
That doesn't provide any method of pagination or scrolling though. –  paraxor Jul 4 '13 at 12:08
    
agreed but this does the job of scrolling automatically and conveniently. –  Raza Jul 4 '13 at 16:42

I almost always use less for this sort of thing. I've never used the "forward forever" mode, instead I've got by just using less's runtime shortcuts for scrolling:-

< - Scroll to beginning of stream

> - Scroll to end of stream

Note, that if the buffer is read from a file, and that file has had new content appended to it since less was first opened, then the new content will be visible, the next time > is pressed, even when not in "forward forever" mode.

share|improve this answer
    
You can also use G to scroll to the end and g to scroll to the beginning, which is useful for vim-users. –  evilsoup Jul 3 '13 at 20:59

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