tee - read stdin and write to both stdout and files
tee [-a] file...
Options you will use
-a, --append- Append to the files instead of overwriting.
Examples
$ echo 'x' | sudo tee /etc/sysctl.d/99-x.confthe way to write a root-owned file
$ make 2>&1 | tee build.logsee the output AND keep it
Gotchas
cmd | tee logmakes $? the exit status of TEE, not cmd. Addset -o pipefailor check ${PIPESTATUS[0]}.
Try tee in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.