tee

Write to stdout and one or more files simultaneously.

low risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

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.

Common flags
FlagMeaning
-a --appendAppend to files instead of overwriting
-i --ignore-interruptsIgnore interrupt signals
Examples
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 →
Pro tip

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.

Related
tail grep
Open the full explainer →More in Text Processing

Reference text is hand-written and may be incomplete — check man tee for your version. Test destructive commands on a non-production system first.