How to write terminal contents into a file

Solution 1:

You can pipe your output to the tee program (description):

my_program ... | tee my_program.log

This will show the ouput on the terminal, but also write it to the file my_program.log

Solution 2:

When you are executing your command from terminal instead of seeing the output on your console you can redirect it straight to a file. While the program runs your the output is going to be written to the file. An example lets say you want to write the contents of your folder with an ls command to a file called list.txt

ls > list.txt

The > operator redirects your output according to your needs.

Solution 3:

Try using the script command. Unfortunately, it puts a lot of control character gobbledegook in the transcript. However, if you see this link at the NCSSM CS Site you will find an imperfect but pretty good solution to the problem.