I opened terminal and ran live-f1 which displays live feed in terminal (text) that 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 the console.

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

How can I do it?

By opening 2nd console and using some command?

Can't get it to work with setterm -dump command.

4 Answers 4


live-f1 redraws the screen with new data by using terminal control characters (ncurses), just like top or mtr. That's why you see all this junk when redirecting to a file or non terminal device.

Unfortunately, live-f1 doesn't provide an option for getting output appropriate to save and later extract data for statistics and such. If you still want to save the output for replaying it later, you can use script.

This will record live-f1 and create two files, typescript and timingfile.

script -c live-f1 -t 2> timingfile

This will replay the output

scriptreplay timingfile

There are a few ways that I use to capture output into a file which may be of use to you.


This creates a subshell and puts all output into it. So do script, then whatever you want, then exit to end your subshell and your output will be in a file called "typescript"


You can echo all of a pipe to somewhere else. So you can tee off your standard output into a file:

$ mycommand | tee myoutput

If you need to capture standard error as well then redirect it:

$ mycommand 2>&1 | tee myoutput

How about running the program like this:

program > /path/to/file

This redirects the output of program to /path/to/file instantly.

And if you want to have the output in your terminal, as well as save it into a file. Check out Is there a way in bash to redirect output and still have it go to stdout?

  • Thank you for quick answer. This almost works, only file contents is bit mangled. It should be in HTML, but instead, when I open the file there's some weird symbols, see the screenshot: upload.ee/image/1223166/ss_01.png. Program's name is live-f1.
    – Gustav
    Mar 26, 2011 at 8:30
  • That looks funny. Are you sure that the program only outputs HTML? Is there any animation or something weird?
    – phunehehe
    Mar 26, 2011 at 8:47
  • This will only redirect standard output. Is standard error required as well? Mar 26, 2011 at 9:00
  • 2
    @Gustav There's ANSI codes trapped in there too. Either your application outputs some sort of progress counter (Which is what it looks like), or colours its output, or similar. If there is some way to turn this off then you will need to use it to capture clean output. Your application doesn't output HTML though, so to capture HTML you will need some other application to translate the output. Mar 26, 2011 at 9:14
  • Why I'm saing it's HTML, because I got it work year ago, but have reformated the disk where I had the working enviroment. My goal is to get Formula 1 drivers' positions from live-f1 feed into a file. I got it work last year by running live-f1 program in 1st terminal, then fireing up 2nd terminal and using some command what captured 1st terminal screen and saved it to a file (copy from last year's file: upload.ee/download/1223347/0b6545ce227661452c8/html.log). Command was something like that: tty "1st terminal pointer" "filename" "interval"
    – Gustav
    Mar 26, 2011 at 10:13

You could use GNU screen, along with its logging functionality. Note also that the logfile flush secs command allows you to control how often the output is flushed to disk. From the Screen User's Manual:

— Command: logfile flush secs

Defines the name the log files will get. The default is ‘screenlog.%n’. The second form changes the number of seconds screen will wait before flushing the logfile buffer to the file-system. The default value is 10 seconds.

  • I'll look into it.
    – Gustav
    Mar 26, 2011 at 10:13

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.