TEE(1) General Commands Manual TEE(1)

teeduplicate standard input

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. The options determine if the specified files are overwritten or appended to.

The tee utility shall conform to the utility argument syntax guidelines described in 2.10.2. The following options shall be supported by the implementation:

Append the output to the files rather than overwriting them.

Ignore the SIGINT signal.

The following operands shall be supported by the implementation:

file

A pathname of an output file. Implementations shall support processing of at least 13 file operands.

The standard input can be of any type.

None.

The following environment variables shall affect the execution of tee:

This variable shall determine the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_ ) do not specify a locale. See 2.6.

This variable shall determine the locale to be used to override any values for locale categories specified by the settings of LANG or any environment variables beginning with LC_.

This variable shall determine the locale for the interpretation of sequences of bytes of text data as characters (e.g., single- versus multibyte characters in arguments).

This variable shall determine the language in which messages should be written.

Default, except that if the −i option was specified, SIGINT shall be ignored.

The standard output shall be a copy of the standard input.

Used only for diagnostic messages.

If any file operands are specified, the standard input shall be copied to each named file.

None.

The standard input was successfully copied to all output files.

An error occurred.

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 nonzero. Otherwise, the default actions specified in 2.11.9 shall apply.

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.

The buffering requirement means that tee is not allowed to use C Standard {7} fully-buffered or line-buffered writes, not that tee has to do one-byte reads followed by one-byte writes. It should be noted that early versions of silently ignore any invalid options, and accept a single − as an alternative to −i. They also print the message " tee: cannot access %s\n", <pathname> if unable to open a file. Historical implementations ignore write errors. This is explicitly not permitted by this standard. Some historical implementations use O_APPEND when providing append mode; others just () to the end of file after opening the file without O_APPEND. This standard requires functionality equivalent to using O_APPEND; see 2.9.1.4.

September 1991 posix.fail