Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

tee - join pipes and make copies of input

&pagelevel(4)&pagelevel

tee transcribes data from standard input to standard output and simultaneously copies this data to the specified file.


Syntax


tee[ -ai][ file...]

-a

(append)

tee appends its output to the original contents of file if file already exists when tee is invoked.

-a not specified:
If file exists when tee is invoked, the original contents of file are overwritten.

-i

(ignore)

The signal SIGINT (see kill) is ignored.

file

Name of the file to which tee is to write its output. If file does not exist when you call tee, a new file is created; if it does exist, tee either overwrites its contents or appends the output to it, depending on whether or not the -a option is used. If you specify more than one file, tee writes its entire output to each file.

file not specified:
tee writes its output to standard output only.

Locale

The following environment variables affect the execution of tee:

LANG

Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined.

LC_ALL

If set to a non-empty string value, override the values of all the other internationalization variables.

LC_CTYPE

Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other.

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.

Example

Use of the tee command in a pipe:

$ (date; who) | tee security| wc -l
       3
$ cat security
Mon Mar 9 16:19:41 MEZ 1995
QM212JNA   term/003     Mar 8 14:06:28
user2      pts/0        Mar 9 16:02:54

The date and who commands send the current date and information on all users currently logged in to standard output. The first pipe redirects this output to tee’s standard input. tee reads this input and copies it to the file security and to standard output. The second pipe sends the standard output of tee to the standard input of the wc -l command; wc -l writes the number of read lines to standard output: 3 (2 users logged in and 1 line for the date).