Oct 2, 2020

Tee in the World of Pipes

Experience has shown that when writing command line tools that handle data, it is worthwhile to log the successfully handled entries. This way if the job dies, you know what you have finished and what you have not finished. This used to be code that I would write into my applications to keep track of the successful and failed entries.

Unix has this wonderful tool called tee that can help with this without having to write any extra code. This is basically a tool that takes input from stdin, and writes it to a file and then outputs it on stdout. You can for example write echo world | tee test.txt. This will print world in your prompt, and at the same time save a file called test.txt with the content world.