Ubuntu – Is it possible to save output from a command to a file after the command already has been executed

command linegnome-terminal

Does an elegant way exist to save the output of a command to a file after the command has been run, while the terminal window is open i.e. once the command has been executed in the terminal?

The output is still present in terminal. Now I could copy & paste all the lines and save it to a file.

But perhaps does a method exist to somehow write the output buffer of a terminal window to a file or even better the output of an already executed command?

Best Answer

You appear to have a number of options, but gnome-terminal doesn't support logging to a file by itself.

  • You can run the script command before your output in order to accomplish this. See this Launchapd Q&A for more.

  • You can install and use a different terminal instead of gnome-terminal, which supports logging all output to a file, such as Putty. There may be others.

  • You can simply highlight the text output you require, then use CTRL-SHIFT-C to copy the text.

Related Question