# Tee (command)

**tee** is a standard Unix command-line utility that copies its standard input to standard output and, at the same time, to zero or more files named as arguments. It is typically placed in a pipeline when data must both flow onward to the next command and be saved to a file, and its name comes from the T-shaped split of a pipe fitting.<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup><sup> • </sup><sup>[2](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+14.2-RELEASE&query=tee&sektion=1)</sup>

| Key fact | Detail |
|---|---|
| Function | Copies standard input to standard output and to each file argument; missing files are created, existing files are overwritten unless `-a` is given<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup> |
| Synopsis | `tee [option]... [file]...`<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup> |
| First appeared | Version 7 AT&T UNIX<sup>[2](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+14.2-RELEASE&query=tee&sektion=1)</sup> |
| Standard options | `-a` (append), `-i` (ignore SIGINT) are specified by POSIX<sup>[3](https://www.linuxman7.org/linux/man-pages/man1/tee.1p.html)</sup> |
| GNU extensions | `-p` and `--output-error[=MODE]` control behavior on write errors, with modes `warn`, `warn-nopipe`, `exit`, and `exit-nopipe`<sup>[4](https://manpages.debian.org/unstable/coreutils/tee.1.en.html)</sup> |
| Exit status | Zero indicates success; nonzero indicates failure<sup>[2](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+14.2-RELEASE&query=tee&sektion=1)</sup> |
| GNU implementation | Written by Mike Parker, Richard M. Stallman, and David MacKenzie, part of GNU Coreutils<sup>[4](https://manpages.debian.org/unstable/coreutils/tee.1.en.html)</sup> |

## Basic behavior

The command reads standard input and writes every byte to standard output and to each file operand. If an output file does not exist it is created; if it exists, its previous contents are overwritten unless the `-a` (`--append`) option is used, in which case input is appended instead.<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup> The FreeBSD implementation states that its output is unbuffered, so data appears at each destination as it is read.<sup>[2](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+14.2-RELEASE&query=tee&sektion=1)</sup>

A minimal example from the FreeBSD manual sends the echoed message both to the terminal and to a file:<sup>[2](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+14.2-RELEASE&query=tee&sektion=1)</sup>

```
echo "Hello" | tee greetings.txt
```

The `-i` option makes tee ignore interrupt signals (SIGINT), so an interrupt aimed at the foreground process group does not terminate the copy while a pipeline is still running.<sup>[3](https://www.linuxman7.org/linux/man-pages/man1/tee.1p.html)</sup>

## Write-error handling in GNU tee

GNU Coreutils tee adds the `-p` option and the long form `--output-error[=MODE]` to control what happens when writing to one output fails, which matters when tee feeds processes that may exit early.<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup> The four modes are:<sup>[4](https://manpages.debian.org/unstable/coreutils/tee.1.en.html)</sup>

- `warn`: diagnose errors on any output, including pipes, and continue writing to outputs that are still open.
- `warn-nopipe`: the same, except errors on pipes are not diagnosed; this is the default mode for `-p`.
- `exit`: exit on an error writing to any output, including pipes.
- `exit-nopipe`: exit on any output error except a broken pipe.

With the "nopipe" modes, tee exits immediately if all remaining outputs become broken pipes. When `--output-error` is not specified at all, the default operation is to exit immediately on an error writing to a pipe and to diagnose errors writing to non-pipe outputs.<sup>[4](https://manpages.debian.org/unstable/coreutils/tee.1.en.html)</sup> The POSIX specification takes a middle position: if a write to one successfully opened file fails, writes to the other files and to standard output continue, but the exit status is nonzero.<sup>[5](https://manpages.ubuntu.com/manpages/stonking/man1/tee.1posix.html)</sup>

## The `-` operand

In GNU Coreutils versions 5.3.0 through 8.23, a file argument of `-` caused tee to send another copy of the input to standard output. Because the resulting interleaved output was not very useful, later versions conform to POSIX and treat `-` as an ordinary file name.<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup>

## Typical uses

**Saving a pipeline's output without rereading it.** The GNU manual's motivating example is verifying a large download. Running the download and then a checksum means waiting for the download to finish and reading the image a second time. With tee, the checksum computation is interleaved with the download:<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup>

```
wget -O - https://example.com/dvd.iso \
  | tee dvd.iso | cksum -a sha2 -l 256 > dvd.sha256
```

Here tee writes the image to `dvd.iso` while passing the same stream down the pipe to the checksum program, so the checksum is computed in parallel with the transfer.<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup>

**Process substitution.** Modern shells such as `zsh`, `bash`, and `ksh` support process substitution, the `>(command)` syntax, which connects a command to a [named pipe](https://www.edgepedia.org/named-pipe); `/bin/sh` does not. This lets tee feed several processes at once, for example computing SHA-256 and SHA3-256 checksums in parallel while still writing the image file:<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup>

```
wget -O - https://example.com/dvd.iso \
  | tee >(cksum -a sha2 -l 256 > dvd.sha256) \
        >(cksum -a sha3 -l 256 > dvd.sha3) \
  > dvd.iso
```

If any of the substituted processes might exit early without consuming all the data, the `-p` option is needed so tee keeps processing input for the remaining outputs.<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup> The same technique compresses a pipe's contents while another command consumes them, as in `du -ak | tee >(gzip -9 > /tmp/du.gz) | checkspace -a`, and can replace sequential `gzip` and `bzip2` tarball creation in automake-generated rules with a single read of the archive followed by parallel compression.<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup>

**Writing privileged files.** Because shell redirection is performed by the shell itself, prefixing a command with `sudo` does not grant the redirection elevated rights.

## Standards and implementations

tee is specified by POSIX: the utility copies standard input to standard output, making a copy in zero or more files, and accepts the `-a` and `-i` options.<sup>[5](https://manpages.ubuntu.com/manpages/stonking/man1/tee.1posix.html)</sup> The FreeBSD manual states the utility is expected to be IEEE Std 1003.2 ("POSIX.2") compatible and takes the default action for all signals except with `-i`.<sup>[2](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+14.2-RELEASE&query=tee&sektion=1)</sup> The GNU implementation is part of GNU Coreutils, whose manual describes tee as the one redirection performed by a separate command rather than by the shell.<sup>[1](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)</sup> The GNU Awk user's guide, which ships a small tee program as an example, calls it a "pipe fitting" that duplicates its input to the files named on the command line.<sup>[6](https://www.gnu.org/s/gawk/manual/html_node/Tee-Program.html)</sup>

## References

1. [tee invocation, GNU Coreutils 9.11 manual](https://www.gnu.org/s/coreutils/manual/html_node/tee-invocation.html)
2. [TEE(1), FreeBSD 14.2-RELEASE Manual Pages](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+14.2-RELEASE&query=tee&sektion=1)
3. [tee(1p), POSIX manual page (Linux man-pages mirror)](https://www.linuxman7.org/linux/man-pages/man1/tee.1p.html)
4. [tee(1), GNU Coreutils, Debian Manpages](https://manpages.debian.org/unstable/coreutils/tee.1.en.html)
5. [tee, POSIX.1-2017 (Ubuntu manpage mirror)](https://manpages.ubuntu.com/manpages/stonking/man1/tee.1posix.html)
6. [Tee Program, The GNU Awk User's Guide](https://www.gnu.org/s/gawk/manual/html_node/Tee-Program.html)

---
*Topic: Encyclopedia › Technology and the built world › Computing and digital systems › Software and programming › Development tools and collaboration infrastructure › Build, deployment, and development tooling*

*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

*Copyright 2026 EdgeChat AI, a subsidiary of Biostate AI.*

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license
