1TEE(1P)                    POSIX Programmer's Manual                   TEE(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       tee — duplicate standard input
13

SYNOPSIS

15       tee [-ai] [file...]
16

DESCRIPTION

18       The tee utility shall copy standard input to standard output, making  a
19       copy in zero or more files. The tee utility shall not buffer output.
20
21       If  the  -a option is not specified, output files shall be written (see
22       Section 1.1.1.4, File Read, Write, and Creation.
23

OPTIONS

25       The tee utility  shall  conform  to  the  Base  Definitions  volume  of
26       POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
27
28       The following options shall be supported:
29
30       -a        Append the output to the files.
31
32       -i        Ignore the SIGINT signal.
33

OPERANDS

35       The following operands shall be supported:
36
37       file      A  pathname  of  an output file. If a file operand is '-', it
38                 shall refer to a file  named  -;  implementations  shall  not
39                 treat  it as meaning standard output.  Processing of at least
40                 13 file operands shall be supported.
41

STDIN

43       The standard input can be of any type.
44

INPUT FILES

46       None.
47

ENVIRONMENT VARIABLES

49       The following environment variables shall affect the execution of tee:
50
51       LANG      Provide a default value for  the  internationalization  vari‐
52                 ables  that are unset or null. (See the Base Definitions vol‐
53                 ume of POSIX.1‐2017, Section 8.2, Internationalization  Vari‐
54                 ables  for  the  precedence of internationalization variables
55                 used to determine the values of locale categories.)
56
57       LC_ALL    If set to a non-empty string value, override  the  values  of
58                 all the other internationalization variables.
59
60       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
61                 bytes of text data as characters (for example, single-byte as
62                 opposed to multi-byte characters in arguments).
63
64       LC_MESSAGES
65                 Determine the locale that should be used to affect the format
66                 and contents  of  diagnostic  messages  written  to  standard
67                 error.
68
69       NLSPATH   Determine the location of message catalogs for the processing
70                 of LC_MESSAGES.
71

ASYNCHRONOUS EVENTS

73       Default, except that if the -i option was specified,  SIGINT  shall  be
74       ignored.
75

STDOUT

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

STDERR

80       The standard error shall be used only for diagnostic messages.
81

OUTPUT FILES

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

EXTENDED DESCRIPTION

87       None.
88

EXIT STATUS

90       The following exit values shall be returned:
91
92        0    The standard input was successfully copied to all output files.
93
94       >0    An error occurred.
95

CONSEQUENCES OF ERRORS

97       If a write to any successfully opened file  operand  fails,  writes  to
98       other  successfully opened file operands and standard output shall con‐
99       tinue, but the exit status shall be non-zero.  Otherwise,  the  default
100       actions specified in Section 1.4, Utility Description Defaults apply.
101
102       The following sections are informative.
103

APPLICATION USAGE

105       The  tee  utility  is usually used in a pipeline, to make a copy of the
106       output of some utility.
107
108       The file operand is technically optional, but tee  is  no  more  useful
109       than cat when none is specified.
110

EXAMPLES

112       Save an unsorted intermediate form of the data in a pipeline:
113
114
115           ... | tee unsorted | sort > sorted
116

RATIONALE

118       The  buffering  requirement  means that tee is not allowed to use ISO C
119       standard fully buffered or line-buffered writes. It does not mean  that
120       tee has to do 1-byte reads followed by 1-byte writes.
121
122       It  should  be  noted  that  early  versions  of BSD ignore any invalid
123       options and accept a single '-' as an alternative  to  -i.   They  also
124       print a message if unable to open a file:
125
126
127           "tee: cannot access %s\n", <pathname>
128
129       Historical  implementations ignore write errors. This is explicitly not
130       permitted by this volume of POSIX.1‐2017.
131
132       Some historical implementations  use  O_APPEND  when  providing  append
133       mode;  others use the lseek() function to seek to the end-of-file after
134       opening the file without O_APPEND. This volume of POSIX.1‐2017 requires
135       functionality  equivalent  to using O_APPEND; see Section 1.1.1.4, File
136       Read, Write, and Creation.
137

FUTURE DIRECTIONS

139       None.
140

SEE ALSO

142       Chapter 1, Introduction, cat
143
144       The Base Definitions volume of  POSIX.1‐2017,  Chapter  8,  Environment
145       Variables, Section 12.2, Utility Syntax Guidelines
146
147       The System Interfaces volume of POSIX.1‐2017, lseek()
148
150       Portions  of  this text are reprinted and reproduced in electronic form
151       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
152       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
153       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
154       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
155       event of any discrepancy between this version and the original IEEE and
156       The  Open Group Standard, the original IEEE and The Open Group Standard
157       is the referee document. The original Standard can be  obtained  online
158       at http://www.opengroup.org/unix/online.html .
159
160       Any  typographical  or  formatting  errors that appear in this page are
161       most likely to have been introduced during the conversion of the source
162       files  to  man page format. To report such errors, see https://www.ker
163       nel.org/doc/man-pages/reporting_bugs.html .
164
165
166
167IEEE/The Open Group                  2017                              TEE(1P)
Impressum