1TEE(P) POSIX Programmer's Manual TEE(P)
2
3
4
6 tee - duplicate standard input
7
9 tee [-ai][file...]
10
12 The tee utility shall copy standard input to standard output, making a
13 copy in zero or more files. The tee utility shall not buffer output.
14
15 If the -a option is not specified, output files shall be written (see
16 File Read, Write, and Creation .
17
19 The tee utility shall conform to the Base Definitions volume of
20 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
21
22 The following options shall be supported:
23
24 -a Append the output to the files.
25
26 -i Ignore the SIGINT signal.
27
28
30 The following operands shall be supported:
31
32 file A pathname of an output file. Processing of at least 13 file op‐
33 erands shall be supported.
34
35
37 The standard input can be of any type.
38
40 None.
41
43 The following environment variables shall affect the execution of tee:
44
45 LANG Provide a default value for the internationalization variables
46 that are unset or null. (See the Base Definitions volume of
47 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
48 ables for the precedence of internationalization variables used
49 to determine the values of locale categories.)
50
51 LC_ALL If set to a non-empty string value, override the values of all
52 the other internationalization variables.
53
54 LC_CTYPE
55 Determine the locale for the interpretation of sequences of
56 bytes of text data as characters (for example, single-byte as
57 opposed to multi-byte characters in arguments).
58
59 LC_MESSAGES
60 Determine the locale that should be used to affect the format
61 and contents of diagnostic messages written to standard error.
62
63 NLSPATH
64 Determine the location of message catalogs for the processing of
65 LC_MESSAGES .
66
67
69 Default, except that if the -i option was specified, SIGINT shall be
70 ignored.
71
73 The standard output shall be a copy of the standard input.
74
76 The standard error shall be used only for diagnostic messages.
77
79 If any file operands are specified, the standard input shall be copied
80 to each named file.
81
83 None.
84
86 The following exit values shall be returned:
87
88 0 The standard input was successfully copied to all output files.
89
90 >0 An error occurred.
91
92
94 If a write to any successfully opened file operand fails, writes to
95 other successfully opened file operands and standard output shall con‐
96 tinue, but the exit status shall be non-zero. Otherwise, the default
97 actions specified in Utility Description Defaults apply.
98
99 The following sections are informative.
100
102 The tee utility is usually used in a pipeline, to make a copy of the
103 output of some utility.
104
105 The file operand is technically optional, but tee is no more useful
106 than cat when none is specified.
107
109 Save an unsorted intermediate form of the data in a pipeline:
110
111
112 ... | tee unsorted | sort > sorted
113
115 The buffering requirement means that tee is not allowed to use ISO C
116 standard fully buffered or line-buffered writes. It does not mean that
117 tee has to do 1-byte reads followed by 1-byte writes.
118
119 It should be noted that early versions of BSD ignore any invalid
120 options and accept a single '-' as an alternative to -i. They also
121 print a message if unable to open a file:
122
123
124 "tee: cannot access %s\n", <pathname>
125
126 Historical implementations ignore write errors. This is explicitly not
127 permitted by this volume of IEEE Std 1003.1-2001.
128
129 Some historical implementations use O_APPEND when providing append
130 mode; others use the lseek() function to seek to the end-of-file after
131 opening the file without O_APPEND. This volume of IEEE Std 1003.1-2001
132 requires functionality equivalent to using O_APPEND; see File Read,
133 Write, and Creation .
134
136 None.
137
139 Introduction , cat , the System Interfaces volume of
140 IEEE Std 1003.1-2001, lseek()
141
143 Portions of this text are reprinted and reproduced in electronic form
144 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
145 -- Portable Operating System Interface (POSIX), The Open Group Base
146 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
147 Electrical and Electronics Engineers, Inc and The Open Group. In the
148 event of any discrepancy between this version and the original IEEE and
149 The Open Group Standard, the original IEEE and The Open Group Standard
150 is the referee document. The original Standard can be obtained online
151 at http://www.opengroup.org/unix/online.html .
152
153
154
155IEEE/The Open Group 2003 TEE(P)