I ran a program that has a good amount of command line output, and it ran on a screen in a ssh server. I referred to this post so that I can scroll through the screen and see the output, but there is too much output and going up line by line is not ideal.

Scroll inside Screen, or Pause Output

I was wondering if there is any way I could just save the screen output or copy all of it at once and paste it to a file.

  • 2
    in a terminal window having a menu bar, Edit - Profile Preferences - Scrolling. Crank it up so you can scroll back far enough. I set it to like 500,000 which says something like 39MB memory needed. Then you can highlight and copy & paste. – ron Aug 19 '19 at 20:48
  • if there is no user interaction then you could simply redirect the output to a file by doing >. For example: ./runmyprogram.x > whatever.log will save all output to a file called whatever.log. – ron Aug 19 '19 at 20:50
  • 2
    Run command like this: command 2>&1 | tee output.txt - this will output everything to stdout and also save it to the output.txt file to review later. – Michal Przybylowicz Aug 19 '19 at 21:00
  • Unfortunately I am ssh-ing into a server and it does not have a menu bar. And the commands to download would work if I reran the program, but it takes 3 days to complete. It has already completed once and I wanted to get the output from there – user367744 Aug 19 '19 at 22:33

You may want to look at script(1) to log terminal output. Using it will create a typescript file that keeps original formatting of anything displayed on the terminal, including escape sequences, the command prompt and spacing among other things.

It can be used by first calling the command script [file] as a standalone command before ssh'ing in. If you don't specify a file it'll be called typescript and be placed in the PWD.
Afterwards, run your commands like usual and when you're done and out of ssh type exit, press Ctrl-D, or use whatever method would usually close your terminal; this will end script instead.

These typescript files can then be read with a command like cat or less -r (Ignoring the binary file warning).

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.