Display a command's output on the screen while saving it to a file, and learn practical tricks to split streams. 16.11.2025 | reading time: 2 min You run a command and want to watch its output while keeping a copy for later; that is what tee does: it reads standard input and writes it to standard output and to files at the same time. A concrete example Demonstration with commands and results: ```bash # show and save system info uname -a | tee system-info.txt # append a line to the same file echo "Snapshot created on $(date)" | tee -a system-info.txt # capture both stdout and stderr into a file while still seeing output ls /nonexistent 2>&1 | tee error.log ``` After the first command the terminal shows the kernel line and the file "system-info.txt" contains exactly the same line; the second command appends a timestamp; the third command prints the error message and also stores it in "error.log". Practical options and tricks Use `-a` to append instead of overwrite and `-i` to ignore SIGINT; to write files requiring root permissions, pipe into sudo tee like `command | sudo tee /etc/somefile`; to split output to multiple consumers use process substitution: `cmd | tee >(gzip > out.gz) other.txt`; remember tee duplicates only stdout by default so redirect stderr with `2>&1` when needed. Related utilities worth knowing When you need progress meters, use `pv`; to record an interactive session, use `script`; when you need to read all input before writing, use `sponge` from moreutils; combine these with tee for powerful pipelines. Parting thought tee is a small tool that gives big control: it lets him observe live output while archiving, filtering, or forwarding it to other tools, and it fits naturally into pipelines; keep experimenting with redirections and process substitution to master Unix pipelines and consider advancing your skills toward certifications such as CompTIA Linux+ or LPIC-1 with intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. utilities scripting backup troubleshooting