Direct output of a program to 2 places

Asked

Viewed 31 times

-2

I know that on Linux or Windows I can redirect the message of a program to be saved in a file instead of being shown at the end of the command >:

./a.out > arqSaida.txt

Or still write at the end of the file instead of overwriting it:

./a.out >> arqSaida.txt

Is there any way to show the output of the program in the terminal so I can track its execution and at the same time save the output in a file? Remember that I only have the compiled program, so I can not change it!

1 answer

2


The command you are looking for is the tee. Your example would look like this, with output in the current terminal and in arqSaida.txt simultaneously:

./a.out | tee arqSaida.txt

Browser other questions tagged

You are not signed in. Login or sign up in order to post.