Unix has some great utilities built in. One of them is the ‘tee’ command, this can be used for creating copies of the output of other commands so you can record it in multiple locations in different ways.
An example of this is below – this line will take the input and write it to two files, one of the files has the input text appended to the end in order to keep an ongoing log, the other file just has the input written to it as a single line only.
$ echo 'bar' | >> append_file.txt tee one_line.txt
If we look at the output of the two files after the above command we see –
$ cat one_line.txt bar $ cat append_file.txt bar
If we run the command again –
$ echo 'foo2' | >> append_file.txt tee one_line.txt
Now we can see what is happening to the two files –
$ cat one_line.txt foo2 $ cat append_file.txt bar foo2
Useful for logging and troubleshooting!