I use printf() in my C++ application to print some information when I run it from Linux command-line. Now, I am using output redirection (./main > output.txt) to save the results into file. I was wondering if it is possible to have both at the same time: see the result in command-line while the program is running, and do output redirection; without explicitly doing it by file I/O in C++.
Asked
Active
Viewed 232 times
1 Answers
8
Do you need a solution in the program? Because if not, you can pipe the output into tee
which takes its input and pumps in into both a file and stdout.

Gabe Sechan
- 90,003
- 9
- 87
- 127
-
Doesn't really matter. In the program or outside. Easier, better. – Sahand Seifi Apr 17 '13 at 05:08
-
'tee' is the right tool for that, and it doesn't only work with C++ programs but any program. – Ulrich Eckhardt Apr 17 '13 at 05:13
-
Seems great, Thanks! Here's a quick sample for other people: [link](http://stackoverflow.com/questions/999120/c-hello-world-boost-tee-example-program) – Sahand Seifi Apr 17 '13 at 05:27