For questions related to Linux syscall and a user program that duplicates the contents of a pipe. For security frameworks, use the tags [trusted-execution-environment] or [op-tee].
Introduction
The tee command reads from standard input and writes to standard output and files.
Examples of writing standard output include:
# print output of ps to a file
$ ps aux | tee ps_aux.txt
Using tee with sudo command
$ echo 'foo' >> file
zsh: permission denied: file
As part of a pipe, tee can take the input and elevate permissions
$ echo "foo" | sudo tee -a file
Links
How do I “tee” variable number of times in a bash “for loop”?