tee
tee
is a command-line utility used to read from standard input and write to standard output and files simultaneously. It is commonly used in pipelines to capture intermediate output.
Basic Syntax
Commonly Used Options
-a
,--append
: Append to the given files, do not overwrite.-i
,--ignore-interrupts
: Ignore interrupt signals.--output-error[=mode]
: Adjust behavior on write errors. Modes includewarn
,warn-nopipe
, andexit
.
Examples
Basic Usage
Write the output of a command to a file and display it on the terminal:
Append to a File
Append the output of a command to a file:
Use with Pipelines
Capture the output of a command in a file while passing it to another command:
Ignore Interrupts
Ignore interrupt signals while writing to a file:
Multiple Files
Write the output to multiple files:
Handle Write Errors
Adjust behavior on write errors:
Conclusion
tee
is a versatile tool for duplicating the output of a command to both standard output and files. Understanding its options allows for efficient and powerful output management in command-line operations.