Direct exit of a program for 2 places

-2

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

./a.out > arqSaida.txt

Or write at the end of the file instead of replacing it:

./a.out >> arqSaida.txt

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

    
asked by anonymous 14.10.2018 / 04:23

1 answer

1

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

./a.out | tee arqSaida.txt
    
14.10.2018 / 05:01