[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 5


tee Command

Purpose

Displays the output of a program and copies it into a file.

Syntax

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

Description

The tee command reads standard input, then writes the output of a program to standard output and simultaneously copies it into the specified file or files.

Flags


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

Exit Status

This command returns the following exit values:

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.

Examples

  1. To view and save the output from a command at the same time:

    lint program.c | tee program.lint
    

    This displays the standard output of the command lint program.c at the workstation, and at the same time saves a copy of it in the file program.lint. If a file named program.lint already exists, it is deleted and replaced.

  2. To view and save the output from a command to an existing file:
    lint program.c | tee  -a program.lint
    This displays the standard output of the lint program.c command at the workstation and at the same time appends a copy of it to the end of the program.lint file. If the program.lint file does not exist, it is created.

Files


/usr/bin/tee Contains the tee command.

Related Information

The script command.

Input and Output Redirection Overview in AIX 5L Version 5.1 System User's Guide: Operating System and Devices describes how the operating system processes input and output and how to use the redirect and pipe symbols.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]