tee
- Command# Command
[command] | tee [output_filename]
# Example
cat file.txt | tee out.log
# Command
[command] | tee -a [output_filename]
# Example
cat file.txt | tee -a out.log
stdout
and stderr
Separately# Command
[command] > >(tee [stdout_filename]) 2> >(tee [stderr_filename] >&2)
# Example
./run_inference_demo.sh > >(tee stdout.log) 2> >(tee stderr.log >&2)