Tee Command Overview
What is the Tee Command?
The tee
command is a powerful Linux utility that reads from standard input and writes to both standard output and one or more files simultaneously.
graph LR
A[Standard Input] --> B[Tee Command]
B --> C[Standard Output]
B --> D[File 1]
B --> E[File 2]
Basic Tee Command Syntax
command | tee [options] file(s)
Key Tee Command Options
Option |
Description |
-a |
Append to files instead of overwriting |
-i |
Ignore interrupt signals |
Practical Usage Examples
Writing Output to Console and File
ls | tee directory_list.txt
Appending Output
echo "New log entry" | tee -a system.log
Capturing Both Standard Output and Error
command 2>&1 | tee output.log
Advanced Tee Scenarios
- Logging command outputs
- Monitoring script execution
- Creating backup copies during pipeline operations
At LabEx, we emphasize the versatility of the tee
command for efficient Linux system management and debugging.