Ubuntu – Where is the output of a Terminal (Gnome Terminal) stored

command linegnome-terminaloutput

First of all, this is not a question about history, which stores all the entered commands.

I have on my workstation at work several open Terminals from which I launch simulations, examine the output and where occasionally error messages are displayed.

In Gnome Terminal there is a setting controlling the length of the scroll back, in my case the setting is set to be just shy of 10000 lines.

Now my question: How can I search the scroll-back?

In my case I want to check whether a recent error message occurred previously.
Yes, I can scroll back and use my eyeballs to search for the error message in question.
But for several Terminals which are potentially up to 10000 lines long, that means a serious time spent scrolling.

I assume the information in the scroll-back needs to be stored somewhere, and if is stored somewhere it might actually be searchable.

[Edit: corrected the question to be about Gnome Terminal.]

Best Answer

If the output produced by your scripts is very important to you (to look for error, warning, actions that were run and so on), then you shouldn't rely on the display of the console you're using.

You have to redirect the output of your scripts to some files, this has advantages :

  • you are no more bounded to the number of lines in the scroll buffer of the console you are using
  • you can archive the result for as long as you want to be able to retrieve what was done, even some days/weeks/months after you effectively run the script
  • you can have the errors logged to a dedicated file, different from the informational messages, making it more easy to find errors. (if the commands used in your scripts send error to STDERR and information to STDOUT).
  • you can even log to a file while still displaying output on the terminal is you use the command tee.

So, you can do this :

./script.sh | tee -a output

to copy all the output of script.sh to a file called output, appending the text to the end of the file and displaying the text on the terminal too.

Related Question