What if you could watch and save your command output at the same time with one simple trick?
Why tee for splitting output in Linux CLI? - Purpose & Use Cases
Imagine you run a command in the terminal that shows important information. You want to see this information on the screen and also save it to a file for later. So, you run the command twice: once to see it, and once to save it. This wastes time and effort.
Running the command twice is slow and can cause mistakes if the command changes or the output differs. Copying and pasting output manually is tiring and error-prone. You might miss some details or save incomplete data.
The tee command solves this by letting you run the command once, showing the output on the screen and saving it to a file at the same time. It splits the output stream, so you don't have to repeat yourself or risk losing data.
command > output.txt cat output.txt
command | tee output.txt
You can easily watch command results live while keeping a perfect saved copy for review or sharing.
When monitoring a server log, you want to see new entries as they appear but also save them for troubleshooting later. Using tee lets you do both without extra steps.
Running commands twice wastes time and risks errors.
tee splits output to screen and file simultaneously.
This makes saving and viewing output easy and reliable.