tee

From Initq

Jump to: navigation, search

Displays or pipes the output of a command and copies it into a file or a variable. It is primarily used in conjunction with pipes and filters. This will show the contents of the ls command and also copy it to a file called zipcodes.

  [alibaba@ohnonono junk]$ ls -la | tee zipcode

Description and syntax

tee is normally used to split the output of a program so that it can be seen on the display and also be saved in a file. The command can also be used to capture intermediate output before the data is altered by another command or program. The tee command reads standard input, then writes its content to standard output and simultaneously copies it into the specified file(s) or variables. The syntax differs depending on the command's implemenation:

Unix-like

tee [ -a ] [ -i ] [ File ... ]

Arguments:

  • File One or more files that will receive the "tee-d" output.

Flags:

  • -a Adds the output to the end of File instead of writing over it.
  • -i Ignores interrupts.

The command returns the following exit values (exit status):

  • 0 The standard input was successfully copied to all output files.
  • >0 An error occurred.

Note: If a write to any successfully opened File operand is not successful, writes to other successfully opened File operands and standard output will continue, but the exit value will be >0.

Personal tools