Sahand Seifi
Sahand Seifi

Reputation: 225

Printing to command-line with output redirection

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++.

Upvotes: 1

Views: 267

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93552

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.

Upvotes: 8

Related Questions