TEE(1P)
๐ TEE(1P) ๐
okay bestie, so this one lives in the POSIX Programmer's Manual, and it's called tee. yes like the shirt. yes it's iconic. no cap.
๐ธ PROLOG ๐ธ
okay so heads up, this page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the deets on Linux behavior), or honestly it might not be implemented on Linux at all. tragic, I know.
โจ NAME โจ
tee โ duplicate standard input. that's it. that's the whole job. queen behavior.
๐ SYNOPSIS ๐
tee [-ai] [file...]
๐ฆ DESCRIPTION ๐ฆ
okay so the tee utility shall copy standard input to standard output, making a copy in zero or more files. like, it's splitting the stream, main character energy fr fr. and here's the spicy part: tee shall not buffer output. nope. not doing it. not today.
if the -a option is not specified, output files shall be written (see Section 1.1.1.4, File Read, Write, and Creation).
lowkey obsessed with how short this description is. it knows what it is. ๐
๐ OPTIONS ๐
the tee utility shall conform to the Base Definitions volume of POSIX.1โ2017, Section 12.2, Utility Syntax Guidelines. so like, it follows the rules, but make it fashion.
the following options shall be supported:
-aโ append the output to the files. (not overwrite. append. know the difference bestie ๐ซถ)-iโ ignore theSIGINTsignal. so like,Ctrl-Ccan't touch this.
๐ OPERANDS ๐
the following operands shall be supported:
fileโ a pathname of an output file. and listen, if a file operand is'-', it shall refer to a file named-. implementations shall not treat it as meaning standard output. like, it's literally just a file whose name is a dash, don't be weird about it. processing of at least 13 file operands shall be supported. thirteen. that's the bar. slay.
๐ STDIN ๐
the standard input can be of any type. no restrictions. it's giving fluid.
๐ INPUT FILES ๐
None.
๐ง ENVIRONMENT VARIABLES ๐ง
the following environment variables shall affect the execution of tee:
LANGโ provide a default value for the internationalization variables that are unset or null. (see the Base Definitions volume of POSIX.1โ2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)LC_ALLโ if set to a non-empty string value, override the values of all the other internationalization variables. it's the boss of the group chat.LC_CTYPEโ determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments).LC_MESSAGESโ determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.NLSPATHโ determine the location of message catalogs for the processing ofLC_MESSAGES.
โก ASYNCHRONOUS EVENTS โก
default, except that if the -i option was specified, SIGINT shall be ignored. so -i is basically a shield. ๐ก๏ธ
โญ STDOUT โญ
the standard output shall be a copy of the standard input. same stream, same vibe.
๐ STDERR ๐
the standard error shall be used only for diagnostic messages. only. for. diagnostics. it's not a hangout spot.
๐ธ OUTPUT FILES ๐ธ
if any file operands are specified, the standard input shall be copied to each named file.
๐ฆ EXTENDED DESCRIPTION ๐ฆ
None. (iconic of it honestly)
๐ EXIT STATUS ๐
the following exit values shall be returned:
0โ the standard input was successfully copied to all output files. we ate. ๐>0โ an error occurred. ๐ญ
๐จ CONSEQUENCES OF ERRORS ๐จ
okay so real talk. 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. like, it keeps going, it just tells you something went wrong. otherwise, the default actions specified in Section 1.4, Utility Description Defaults apply.
the following sections are informative. (so like, they're the commentary track, not the law ๐ )
๐ APPLICATION USAGE ๐
the tee utility is usually used in a pipeline, to make a copy of the output of some utility. classic pipeline move.
the file operand is technically optional, but tee is no more useful than cat when none is specified. ๐ญ not the shade but also... it's true bestie. if you're not saving anything you're just cat with extra steps.
๐ EXAMPLES ๐
save an unsorted intermediate form of the data in a pipeline:
... | tee unsorted | sort > sorted
like, you get the raw version AND the sorted version. both. you don't have to choose. that's the whole point. ๐ซถ
๐ง RATIONALE ๐ง
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. so like, calm down, nobody said byte-by-byte. ๐
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 POSIX.1โ2017. so don't do that. periodt.
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 POSIX.1โ2017 requires functionality equivalent to using O_APPEND; see Section 1.1.1.4, File Read, Write, and Creation.
๐ฎ FUTURE DIRECTIONS ๐ฎ
None.
๐ SEE ALSO ๐
- Chapter 1, Introduction,
cat - the Base Definitions volume of POSIX.1โ2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
- the System Interfaces volume of POSIX.1โ2017,
lseek()
๐ COPYRIGHT ๐
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page bestie!! brought to you by IEEE/The Open Group, 2017 edition, from the TEE(1P) page โ ily, go pipe something into a file ๐โจ๐๐ฆ๐ธ๐ ๐ซถ
๐ฆ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 ยท custom
- alpine 3.23: man-pages-posix 2017a-r0 ยท custom
- alpine 3.24: man-pages-posix 2017a-r0 ยท custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 ยท SUSE-IEEE
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms