tee [-ai][file...]
The tee utility shall copy standard input to standard output, making a copy in zero or more files. The tee utility shall not buffer output.
If the -a option is not specified, output files shall be written (see File Read, Write, and Creation .
The tee utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
The following options shall be supported:
The following operands shall be supported:
The standard input can be of any type.
None.
The following environment variables shall affect the execution of tee:
Default, except that if the -i option was specified, SIGINT shall be ignored.
The standard output shall be a copy of the standard input.
The standard error shall be used only for diagnostic messages.
If any file operands are specified, the standard input shall be copied to each named file.
None.
The following exit values shall be returned:
If a write to any successfully opened file operand fails, writes to other successfully opened file operands and standard output shall continue, but the exit status shall be non-zero. Otherwise, the default actions specified in Utility Description Defaults apply.
The following sections are informative.
The tee utility is usually used in a pipeline, to make a copy of the output of some utility.
The file operand is technically optional, but tee is no more useful than cat when none is specified.
Save an unsorted intermediate form of the data in a pipeline:
... | tee unsorted | sort > sorted
The buffering requirement means that tee is not allowed to use ISO C standard fully buffered or line-buffered writes. It does not mean that tee has to do 1-byte reads followed by 1-byte writes.
It should be noted that early versions of BSD ignore any invalid options and accept a single ’-’ as an alternative to -i. They also print a message if unable to open a file:
"tee: cannot access %s\n", <pathname>
Historical implementations ignore write errors. This is explicitly not permitted by this volume of IEEE Std 1003.1-2001.
Some historical implementations use O_APPEND when providing append mode; others use the lseek() function to seek to the end-of-file after opening the file without O_APPEND. This volume of IEEE Std 1003.1-2001 requires functionality equivalent to using O_APPEND; see File Read, Write, and Creation .
None.
Introduction , cat , the System Interfaces volume of IEEE Std 1003.1-2001, lseek()