Ubuntu – How to write terminal contents into a file

command line

Here's my situation:
I open terminal and run program which displays live feed in terminal (text) what changes every second. Only "Enter" key can be used while this program is running (it exits that program). So you can't type anything else into console.

I would like to write that terminal contents into a file, like after every second.

How do I do it? By opening 2nd console and using some command? Can't get it work with setterm -dump command.

Best Answer

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