Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know that I can redirect stdout to a file before running a script, but is there a way to access the whole output of a program that already ran? When the output is too long it gets cut out by the terminal window and I can't see the initial prints.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

There are a couple of suggestions:

  1. increase the number of retained lines in your terminal window. On all of the systems I can, I usually have it set to something like 10,000 lines (or the max possible is less).
  2. (probably slightly more practical) When you know you might want to be able to capture output, start a new bash shell running and pipe the output to a file with tee (bash | tee record.txt). Any output from commands run in that shell will be put into the file "record.txt". Unfortunately, it does not capture input (including the commands you type) and shell prompts.
  3. (better) Before executing anything you think you might want to safe, use script. This will start capturing both your input and program output. When you are finished with stuff, exit the shell or type Ctrl-D. Note: the output generated by script may not be written until 'script' is finished.
share|improve this answer
3  
You can use the script command to capture everything, including prompts and user-input. Adding it to your .profile might be a step too far though. –  RedGrittyBrick Jul 29 '11 at 15:10
    
@RedGrittyBrick Cool, I learned something new today! –  jwernerny Jul 29 '11 at 17:16
    
Thanks for the suggestions. So if I run the script without any of these options, everything that goes off the screen is lost forever. Is this correct? I thought that the output could be saved somewhere (for example, bash_history automatically records what I write). –  nmat Jul 30 '11 at 5:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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