Where is terminal output stored

gtkterminalterminal-emulator

I open lxterminal, which shows up in ps output as x-terminal-emulator. I then enter a command which prints it's output to STDOUT, which is visible on my screen. The command finishes, and I am shown another prompt.

The output of the previous command is still visible, so I can copy and paste it by GUI text selection, but I would like to be able to access it from a script.

Options for accessing this output that I can imagine:

  1. Is it stored somewhere, like in /dev?
  2. Is it in memory somewhere that I could read with low-level tools?
  3. Can I script my terminal emulator to store the output of every command while still outputting it normally?
  4. Is there a tool to scrape text from GTK windows that could access the full terminal window contents?

Best Answer

Regarding number (3), you could put "script -a <file>" in your .bashrc / .bash_profile / etc. which will save all commands in your terminal session.