2

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?

3 Answers3

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,380
  • 2
    +1. tmux can also do this, in any terminal emulator. see 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.
0

Similar to question at: Save all the terminal output to a file

For xfce4-terminal use the accels.scm file.

For instance, to reassign Ctrl-Shift-s from 'set title' to 'save contents' Open to edit: ~/.config/xfce4/terminal/accels.scm

Then search for 'save-contents' and modify the line as follows:

(gtk_accel_path "<Actions>/terminal-window/save-contents" "<Primary><Shift>s")

; This will map 'save the entire scrollback buffer to a file' to the Left_Ctrl-Shift-s keystrokes.

; NOTE: commented lines start with a ;

Within an xfce4-terminal select 'Terminal, Save contents..' or simply Left_Ctrl-Shift-s.

A filemanager will will open to allow you to select where to save the file containing the screen buffer output.

1of7
  • 11
  • 3