6

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

10
  • Where's this Bash setting for scrollback?
    – Oli
    Sep 3, 2014 at 10:25
  • 2
    @Oli presumably he's talking of the terminal's scrollback buffer.
    – muru
    Sep 3, 2014 at 10:35
  • It isn't stored in a file, and I don't think Gnome Terminal offers this feature. You can save all the output to file and then search the file - askubuntu.com/q/161935/158442 This cannot be done post-fact.
    – muru
    Sep 3, 2014 at 10:37
  • My language setting is German, but when I translate it is Edit -> Profile settings and then a tab named Bildlauf in German. The version is Gnome Terminal 3.4.1.1. Sorry for posting initially, that its bash.
    – Dohn Joe
    Sep 3, 2014 at 10:37
  • 3
    if you use gnome-terminal you can search error message in output terminal window, there is already search in top bar in terminal
    – kenn
    Sep 3, 2014 at 10:41

2 Answers 2

3

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.

2
  • Right now I call script.sh > logFile &. This puts all standard output into the log file. Occasionally, I check with tail logFile the status of the simulation. However, all error messages written to STDERR are still printed to the Terminal and not into the file. Is it possible to apply tee only to STDERR?
    – Dohn Joe
    Sep 3, 2014 at 12:12
  • > is redirection of standard output, 2> is redirection of error output, so if you do not use tee, you have to type ./script.sh >output 2>error or ./script.sh >output 2>&1 if you want standard & error output in the same file.
    – Benoit
    Sep 3, 2014 at 12:15
1

The scrollback buffer is a function of your terminal or console.

If you are using the framebuffer console, it's possible to use the fbcon=scrollback: parameter at boot time to increase the size of the scrollback.

For the xfce4-terminal, go to "Edit->Settings->General->Scrollback" and change the scroll-buffer to your likings.

for kde's konsole, go to "Settings->Configure current Profile...->Scrolling->Fixed number of lines"

the classical xterm can be configured with a startup-flag -sl 777 (for 777 lines of scroll-back buffer) or via the saveLines config.

For GNU screen, start it with screen -h .

I'd go with screen, in which you can search the scrollback buffer:

/ Vi-like search forward
? Vi-like search backward
C-a s Emacs style incremental search forward
C-r Emacs style reverse i-search

In scrollback mode (or copy mode, it is the same) you can also copy and paste text.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .