1

This: Save all the terminal output to a file

Except after the fact. Meaning that instead of preparing to record or pipe all output to a file, I am dealing with output that has already taken place, and that I omitted to record to a file. Rather than to spend minutes scrolling up 7000 lines of output, copying and pasting that to a document, I have to think there is an easier way to get the current output.

Considering that this may depend upon the terminal emulator, I am using Konsole and zsh in this case.

How can I save the terminal output to a file after the fact?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175

2 Answers2

4

With konsole, File->Save output as works as does CTRL-SHIFT-S, but you will only save what is in the buffer.

Bib
  • 2,056
  • 1
  • 4
  • 10
  • 2
    +1. `tmux` can also do this, in any terminal emulator. see [Write all tmux scrollback to a file](https://unix.stackexchange.com/questions/26548/write-all-tmux-scrollback-to-a-file). note, though, that if you're running tmux on a remote host (e.g. via ssh) then the buffer will be saved on the remote host, not on the local machine you're running your terminal emulator on. – cas Oct 16 '21 at 14:03
0

I use script for this matter. It's easy, simple, and out of the box.

  • First invoke script in your terminal:
# script output.txt
Script started, file is output.txt
  • Start running your commands normally.

  • Once you decided to get your commands and all the outputs, run exit:

# exit
exit
Script done, file is output.txt
  • All your outputs will be in output.txt.