Previous | Table of Contents | Next |
DESCRIPTION
The external tee command is used to write to the standard output and to a file simultaneously . You place the tee command anywhere in a pipe command to divert a copy of the standard input (of tee ) to disk and another copy to your terminal. Thus its name is from the world of plumbing; it allows one input and two outputs. The tee command actually allows multiple file copies. For example,
sort unsorted tee sorted cut -c-20,41- tee cutup lp
sorts the data in the file unsorted ; tee then sends a copy to the file sort ed. The standard output of tee is piped to cut which removes columns 21 through 40 and pipes it to another tee . The second tee writes a copy to the file cutup and pipes a copy to lp for printing.
COMMAND FORMAT
Following is the general format of the tee command.
tee [ -ai ] file_list
Options
The following options may be used to control how tee functions.
-a | Appends the output to an existing file. If the file does not exist it will be created. Normally an existing file would be overwritten. |
-i | Ignore interrupts. If you press the Delete key, tee ignores the interrupt signal sent to it and continues processing. |
Arguments
The following argument may be passed to the tee command.
file_list | One or more files where tee writes copies of the input. |
RELATED FILES
The tee command reads from the standard input and writes to the standard output and any files listed on the command line.
APPLICATIONS
You can use the tee command to execute a command interactively (in foreground) and save a copy of the output on disk. The tee command can be placed anywhere in a pipe to check what the output looks like at a certain point. Thus it lends itself to debugging pipe commands and capturing output for later perusal.
TYPICAL OPERATION
In this activity you use the tee command to receive input from the sort command, send the output to the printer, and store a copy in a file. Begin at the shell prompt.
| |
BSD (Berkeley) | |
---|---|
Type nawk -F: { print $1} /etc/passwd sort tee users lpr and press Return . | |
|
Previous | Table of Contents | Next |