tee
Save and see.
When you redirect into a file, you can't see the output any more. But sometimes you want both. See it on screen, and save a copy. That's what tee does.

- Redirect hides the output
- Sometimes you want both
- tee: save and see
Tee splits the stream
Tee is named after a T shaped pipe fitting, that splits water two ways. Here, grep finds the errors, and tee writes them into errors dot log, while also printing them on the screen. And WC dash L shows the file got all seven lines too.
grep ERROR logs/server.log | tee errors.log 2026-01-05 09:00:23 ERROR priya failed /home 2026-01-05 09:07:00 ERROR jo failed /shop 2026-01-05 09:09:18 ERROR priya failed /home 2026-01-05 09:11:08 ERROR priya failed /home 2026-01-05 09:17:21 ERROR alex failed /shop 2026-01-05 09:17:56 ERROR alex failed /home 2026-01-05 09:23:28 ERROR priya failed /cart wc -l errors.log 7 errors.log
Useful tee options
Dash A makes tee append, instead of replacing, just like two greater than signs. And tee can sit in the middle of a pipeline, saving a snapshot of the data, while it flows on to the next command. You'll also see tee used with sudo, to write into protected system files.
| key | value |
|---|---|
| cmd | tee file | save and show |
| tee -a | append |
| Mid-pipeline | save a snapshot |
| sudo tee | write system files |
Summary
Tee shows output on screen, and saves it to a file, at the same time. Next, running several commands in one line.
Key takeaways- cmd | tee file
- tee -a appends
- Works mid-pipeline