Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I make extensive use of the functions to navigate through the command history in my terminal; I wonder if there is some way to navigate the command output history as well? (besides keeping a large histsize and leaning on the pgup key)

I cannot just 'rerun the command', as in my particular situation the source of the commands changes; I frequently need to look back at the output of a previous change.

Hacks welcome.


Edit 2010:

I've given 'tee' the credit; among all the methods to log your session elsewhere, it's the most broadly applicable (i.e. it's part of gnu coreutils, and doesnt require a specific shell or utility to work). It wasn't really what I was looking for, but I realize that such a thing doesn't really exist.

The closest approximation I can think of is to use something like screen (byobu/tmux) that logs to file, and write (and keybind) a custom command to page/search through that logfile (think less paging by prompt rather than screen). Thanks everyone.

Edit 2012:

@Dustin Kirkland's answer is clearly best, at least generally; the terminal's scrollback buffer is least-intrusive way to navigate command output history. Byobu appears to have a large default number of history lines saved (10K; tmux has 2K, GNU screen 100), and it allows regex searches (a cursory look indicates that GNU screen has no scrollback search, and tmux has only plaintext search).

share|improve this question

migrated from Sep 10 '10 at 0:29

This question came from our site for professional and enthusiast programmers.

6 Answers 6

up vote 1 down vote accepted

You mention using byobu...

That's certainly one way of doing it. Byobu stores 10K lines of scrollback history per window or per split (pane).

You can enter scrollback easily by pressing Alt-PageUp, Alt-PageDown, or F7. Once you're in scrollback mode, you can search forward and backward using vi-like commands. Use /regex to search forward, and ?regex to search backward.

share|improve this answer

You can use tee to send your command output to a file and to the terminal at the same time.

share|improve this answer

You can use script to log your terminal session to a file. If you always want this to happen then add a suitable script command to your .login.

$ man script

share|improve this answer

screen can be set to log output.

One way to start it, within a running screen session, is to press Ctrl-a, then :, then enter log.

From man screen:

log [on|off]

Start/stop writing output of the current window to a file "screenlog.n" in the 
window's default directory, where n is the number  of  the  current  window.
This filename can be changed with the `logfile' command. If no parameter is
given, the state of logging is toggled. The session log is appended to the
previous contents of the file if it already  exists.  The current contents and
the contents of the scrollback history are not included in the session log.
Default is `off'.

logfile filename
logfile flush secs

Defines  the  name  the  log files will get. The default is "screenlog.%n". The 
second form changes the number of seconds screen will wait before flushing the
logfile buffer to the file-system. The default value is 10 seconds.
share|improve this answer
@SQB: I've expanded my answer. – Dennis Williamson Jul 22 at 16:48

use screen -L

after exiting shell session (exit command) you get a logfile in the same directory you started screen

then you can view the output with more or less -R

share|improve this answer

bash does keep the history of what you did, but not the output from the commands. It could potentially be huge and frequently isn't useful.

share|improve this answer

Your Answer


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.