TEE(1POSIX)

πŸ’– TEE(1POSIX) β€” the POSIX Programmer's Manual, but make it a group chat πŸ’–

okay bestie so this is the TEE(1POSIX) page from the POSIX Programmer's Manual, and I need you to know before we even start: the Linux version of this interface may lowkey be different (go check the matching Linux man page for the deets on Linux behavior), or honestly it might not even be implemented on Linux at all. πŸ™ˆ


🌸 PROLOG 🌸

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β€” so consult the corresponding Linux manual page for details on Linux behavior β€” or the interface may not be implemented on Linux. that's it that's the prolog, moving on 🫢


✨ NAME ✨

tee β€” duplicate standard input. it's giving copy-paste but make it a whole utility πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

tee [-ai] [file...]

πŸ¦‹ DESCRIPTION πŸ¦‹

The tee utility shall copy standard input to standard output, and also make a copy in zero or more files. zero, bestie. it works with zero files. it's fine. it's just kind of pointless then, more on that later 😭

The tee utility shall not buffer output. no cap, no buffering, that's the whole vibe.

If the -a option is not specified, output files shall be written (see Section 1.1.1.4, File Read, Write, and Creation).


πŸ’œ OPTIONS πŸ’œ

The tee utility shall conform to the Base Definitions volume of POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines. slay, syntax guidelines, we love to see it ✨

The following options shall be supported:

  • -a β€” Append the output to the files. no overwriting, just adding, we're being polite πŸŽ€
  • -i β€” Ignore the SIGINT signal. as in, that Ctrl-C energy is not gonna land, bestie πŸ™ˆ

🌈 OPERANDS 🌈

The following operands shall be supported:

  • file β€” A pathname of an output file. If a file operand is -, it shall refer to a file named -; implementations shall not treat it as meaning standard output. ⚠️ literally a file whose name is a single dash, do not get it twisted. Processing of at least 13 file operands shall be supported. thirteen. iconic number. no notes. πŸ”₯

πŸ’… STDIN πŸ’…

The standard input can be of any type. any type. no restrictions, we're open-minded here πŸ¦‹


⭐ INPUT FILES ⭐

None. nothing. nada. empty. we simply do not have input files, bestie πŸ’€


πŸ’– 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.) she's the backup plan for the other locale vars, periodt.
  • LC_ALL β€” If set to a non-empty string value, override the values of all the other internationalization variables. main character energy, she overrides everyone πŸ‘‘
  • 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 of LC_MESSAGES.

🌸 ASYNCHRONOUS EVENTS 🌸

Default, except that if the -i option was specified, SIGINT shall be ignored. so like, normal behavior, unless you said -i, in which case that signal gets ghosted πŸ™ˆ


✨ STDOUT ✨

The standard output shall be a copy of the standard input. that's the entire job description bestie πŸ’…


πŸŽ€ STDERR πŸŽ€

The standard error shall be used only for diagnostic messages. only. it's not a vibe channel, it's a diagnostics channel 😀


πŸ¦‹ OUTPUT FILES πŸ¦‹

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


πŸ’œ EXTENDED DESCRIPTION πŸ’œ

None. there's no extended description. nothing to elaborate on. we said what we said πŸ’€


🌈 EXIT STATUS 🌈

The following exit values shall be returned:

  • 0 β€” The standard input was successfully copied to all output files. ate. πŸ’…
  • >0 β€” An error occurred. 😭

πŸ’– 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 non-zero. so she keeps going, she's resilient, but she's not pretending everything's fine, she's gonna tell you with her exit code πŸ”₯

Otherwise, the default actions specified in Section 1.4, Utility Description Defaults apply.

The following sections are informative. as in, they're here for the lore, not the law πŸ“–βœ¨

⭐ APPLICATION USAGE ⭐

The tee utility is usually used in a pipeline, to make a copy of the output of some utility. that's her moment, that's her whole thing πŸ’…

The file operand is technically optional, but tee is no more useful than cat when none is specified. i'm sorry bestie someone had to say it πŸ˜­πŸ’€


🌸 EXAMPLES 🌸

Save an unsorted intermediate form of the data in a pipeline:

... | tee unsorted | sort > sorted

see? iconic. keeping the messy version and the sorted version. both. slay πŸŽ€


πŸ¦‹ 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. read that twice bestie, because people get it wrong every single time πŸ™ˆ

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. like, absolutely not, we do not do that here ⚠️

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. so like, either road, same destination, but O_APPEND-equivalent is the requirement ✨


πŸ’œ FUTURE DIRECTIONS πŸ’œ

None. the future is... nothing new here. she's done evolving, she's perfect as is πŸ’…


🌈 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()

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 β€” yeah that's the source and the date, we're crediting the icons properly πŸ‘‘βœ¨

πŸ“¦ where this page comes from