NAME
tee — duplicate
standard input
SYNOPSIS
tee |
[-ai] [file
...] |
DESCRIPTION
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.
OPTIONS
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:
OPERANDS
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.
STANDARD INPUT
The standard input can be of any type.
INPUT FILES
None.
ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of
tee:
LANG-
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.
LC_ALL-
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_.
LC_CTYPE-
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).
LC_MESSAGES-
This variable shall determine the language in which messages should be written.
ASYNCHRONOUS EVENTS
Default, except that if the −i option was specified, SIGINT shall be ignored.
STANDARD OUTPUT
The standard output shall be a copy of the standard input.
STANDARD ERROR
Used only for diagnostic messages.
OUTPUT FILES
If any file operands are specified, the standard input shall be copied to each named file.
EXTENDED DESCRIPTION
None.
EXIT STATUS
CONSEQUENCES OF ERRORS
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.
RATIONALE
EXAMPLES
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.
HISTORY OF DECISIONS MADE
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
BSD 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
lseek()
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.