Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

tee

Duplicate standard input (POSIX)

Syntax:

tee [-ai] [file... ]

Runs on:

All supported hosts.

Options:

-a
Append output to the specified file rather than overwriting it.
-i
Ignore the SIGINT signal.
file
A pathname of an output file. If you don't specify any files, tee writes to the standard output.

Description:

The tee utility copies standard input to standard output, making a copy in zero or more files. It doesn't buffer its output. You usually use tee in a pipeline, in order to make a copy of the output of a utility.

If -a is specified, the named file is opened for appending and data from tee is added to the file's existing data. If -a isn't specified, the file is opened for writing and the original data in the file is lost.

While it normally takes the default action for all signals, tee ignores SIGINT if -i is specified.

Examples:

Look for some spots in a collection of C programs where a variable count looks like it's being assigned a value, and tee the output both to standard output (where you can see it immediately) and a file output where you can look at it later (note the grep example here isn't sufficient for an exhaustive examination of where count might be assigned a value):

grep 'count *[^+-/\*]\{,1\}= *[!-([:alnum:]]' | tee output

Files:

An output file is created for each file operand.

Exit status:

0
Success.
> 0
An error occurred.

Errors:

If a write to any successfully opened file fails, writes to standard output and other successfully opened files continue. The exit status, however, is nonzero.