Wednesday, June 27, 2018

tee command vs redirect symbol

Usually I make use of > to redirect to a file.

We can also redirect using tee command.

Something like:

./test | tee test_output.log
So, here instead of > we are using tee.

What is advantage/ difference?

tee in addition to redirection copies the data to STDOUT.

Also, sometimes we want to see only specific lines with a pattern , we can use like:

./runprogram | tee program.log | grep Error
So, in this example, it logs all output , but displays only those lines with "Error".

Ref: man tee 

No comments:

Post a Comment