Write to stdout and one or more files simultaneously.
low risk
tee reads from stdin and writes to both stdout and specified files simultaneously — splitting the pipeline. Essential when you want to log output while still piping it to another command.
| Flag | Meaning |
|---|---|
-a --append | Append to files instead of overwriting |
-i --ignore-interrupts | Ignore interrupt signals |
terraform apply | tee apply.logApply and log output simultaneously · explain & risk-check →kubectl get pods | tee pods.txt | grep RunningSave and filter in one step · explain & risk-check →echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/99-forward.confWrite to privileged file via sudo tee · explain & risk-check →Use `sudo tee` instead of `sudo echo >` when writing to privileged files — `sudo echo >` doesn't work because redirection happens in the user shell, not as root.
Reference text is hand-written and may be incomplete — check man tee for your version. Test destructive commands on a non-production system first.