Say I have a Zsh script and that I would like to let it print output to
STDOUT, but also copy (dump) its output to a file in disk.
Moreover, the script starts with the following option
set -o xtrace
which forces it to be verbose and print what commands it runs. I would like to capture this output as well in a file in disk.
My understanding is that if I do
./my_script.sh > log.txt
it will just send
log.txt, but what if I want to also be able to see the output in the terminal?
I have read about
tee and the
MULTIOS option in Zsh, but am not sure how to use them.
When I do:
./my_script | tee log.txt
I can see the output on the terminal, but the file
log.txt doesn'tseem to be capturing everything (in fact it captures barely anything).