I'm usually inside GNU Screen or tmux, and that doesn't give me great 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.

This question is related but far from specific. I'm really looking for something that lets me scroll.

  • the thing that makes this mildly "not a duplicate" is that you're using tmux and in tmux you can press ctrl+b, [ to enter scroll mode. i'm sure you're aware. but many others may not be: depending on your term, you can then use pgup+pgdn and arrow keys to navigate the backlog, or scroll with your mouse; to exit scroll mode you press q // you can continue using tail -f, or less +F, or cat or scroll an entire bash session for that matter.. it's rare to "need to" invoke less just to scroll through a wall of text. Jan 6 '17 at 8:23
  • if you find tmux hotkeys are "not that great" you may find how-can-i-page-up-or-down-in-tmux-with-terminal-app useful for customizing (or correcting) your configuration -- i've had bad (default) term configs that rendered extended keys useless. Jan 6 '17 at 8:30

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.

  • Great tip, though it's actually Shift+F to resume (at least on my machine) Oct 19 '18 at 11:18
  • A related option I find useful is --follow-name. So less --follow-name +F. This will cause less to periodically reopen the file as it follows. This extra option is not needed if the file you are following is being updated normally, but if instead of being updated normally, the file is instead being overwritten with a new file of the same name, then --follow-name will make it work as expected.
    – Cory Gross
    Apr 20 at 0:50

Well you can use

tail -f <file> | less

then you can have the best of both worlds!

  • 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.
    – user26112
    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

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

   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.
  • That doesn't provide any method of pagination or scrolling though.
    – user26112
    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.

  • 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.