user1426692
user1426692

Reputation: 83

how to use tee without pipes

I want to redirect a program's stdout and stderr to a file and print it to screen at the same time, the obvious solution is to use tee:

./my_program 2>&1 | tee log_file

However, because tee isn't activate until the program finishes execution, I can't see the program output in real-time.

Is there a way to have the same effect while being able to see what a program prints in real-time ?

Upvotes: 0

Views: 877

Answers (1)

merlin2011
merlin2011

Reputation: 75565

Yes, redirect to a file directly and use tail -f to follow the output.

First Terminal Window

./my_program 2>&1 > log_file

Second Terminal Window

tail -f log_file

Upvotes: 2

Related Questions