Using Tee to Output to File and Screen

2016



NOTE:- While this works fine for scripts run from the command line, I found anything run by CRON failed if this format was used (this was on Raspbian Jessie).

When you want to redirect the output of a command to a file you can use the redirector >

  ls -al > result.log


However, this means that you see nothing on the screen, to avoid this use the Tee Command:

  ls -al | tee result.log


Now you get the result on both the screen and in the file.