There are, of course, many ways to save terminal output to a file. However, all the ones I know of require you execute them before the commands who's output you want to save. Is there a command for saving terminal output that's already in the terminal?

  • Not really, unless your terminal emulator allows you save the contents of its history buffer. Anything that has already been sent to stdout or stderr and displayed on the terminal is in the past, and isn't something that's really able to be "seen" by the shell anymore.
    – DopeGhoti
    Aug 3 '20 at 21:34
  • I've seen Luke Smith's video on Youtube explaining his version of simple terminal that allows him to copy the output of previous commands without re-running the command. But I can't remember which one.
    – annahri
    Aug 4 '20 at 7:17

You may want to change your problem by using a terminal multiplexer like screen or tmux. With tmux you can save a selected text from the buffer with the following key command.

  • Ctrl+B, [
  • move to the start of the selection you want to save
  • Space
  • move to the end of selection
  • Enter

You can then paste the content of the selection with Ctrl+B,], in a text editor for example.

screen has the Ctrl+A,H to copy the current content of the window in a file named hardcopy.<n>


This can be dependent on the terminal you’re using and if you’re using a GUI at all. if you are then the easiest and most common way would be to

  • triple-click the last line
  • press shifthome or
  • press shiftclick first line
  • Then either right click copy or CtrlShiftc or right click the top bar of your terminal click Edit-copy (can also select all from there) and paste

Command line tools for this would be xsel and yank But again this is depending on your distro. If you could provide some more info I could be more specific with a solution


On FreeBSD there's


To record terminal sessions. I'm sure it's also available on Linux.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.