Concept Flow - tee for splitting output
Run command producing output
Output stream sent to tee
Write to file
End of process
The command output is sent to tee, which splits it to both a file and the screen simultaneously.
echo "Hello World" | tee output.txt| Step | Action | Input | Output to Screen | Output to File |
|---|---|---|---|---|
| 1 | Run echo command | No input | Hello World | |
| 2 | Pipe output to tee | Hello World | Hello World | Hello World |
| 3 | tee writes to file | Hello World | Hello World | Hello World |
| 4 | tee outputs to screen | Hello World | Hello World | Hello World |
| 5 | Process ends | No input | Hello World displayed | File saved |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|---|
| Output Stream | empty | Hello World | Hello World | Hello World | Hello World |
| File output.txt | empty | empty | Hello World | Hello World | Hello World |
| Screen output | empty | Hello World | Hello World | Hello World | Hello World |
tee command duplicates output streams. Syntax: command | tee filename Outputs go to both screen and file. Overwrites file by default. Use -a to append instead of overwrite.