Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My output prints approximately 1 line per second to the terminal, maybe 100-200 lines in total.

I've tried to capture the output using tee, but it prints all the lines at the end of the process, not in realtime.

I also tried using the script command, but the output file had some weird characters such as ^M printed along with the results, which is no good.

How can I print in realtime while capturing!?

share|improve this question
While the question is not very clear.. like what is ouput where are you capturing.. but watch may serve your purpose. – Web-E Sep 25 '13 at 11:56
up vote 0 down vote accepted

You need to change the output buffer behaviour of your program with something like stdbuf(1):

stdbuf -oL brasteins-program | tee brasteins-program.log
share|improve this answer
Aww yeeeaaahhhh, worked like a charm! Thanks David! I'd upvote you but I don't have enough rep yet :( – brastein Sep 25 '13 at 12:50
Accepting the answer is worth more karma and more helpful to future readers anyway. :-] – David Foerster Sep 25 '13 at 12:53
Btw, just checked your profile, I went to HSU as well :D – brastein Sep 25 '13 at 12:53
My bad, thought I read HSU, not HU in Berlin. Oh well, cheers anyway. – brastein Sep 25 '13 at 12:57

Your Answer


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.