# tee

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## NAME



           tee — duplicate standard input
    


## SYNOPSIS



           tee **[** -ai**] [**_file_...**]**
    


## DESCRIPTION



           The _tee_ utility shall copy standard input to standard output,
           making a copy in zero or more files. The _tee_ utility shall not
           buffer output.
    
           If the **-a** option is not specified, output files shall be written
           (see _Section 1.1.1.4_ , _File Read_ , _Write_ , _and Creation_.
    


## OPTIONS



           The _tee_ utility shall conform to the Base Definitions volume of
           POSIX.1‐2017, _Section 12.2_ , _Utility Syntax Guidelines_.
    
           The following options shall be supported:
    
           **-a** Append the output to the files.
    
           **-i** Ignore the SIGINT signal.
    


## OPERANDS



           The following operands shall be supported:
    
           _file_      A pathname of an output file. If a _file_ operand is **'-'** ,
                     it shall refer to a file named **-** ; implementations shall
                     not treat it as meaning standard output.  Processing of
                     at least 13 _file_ operands shall be supported.
    


## STDIN



           The standard input can be of any type.
    


## INPUT FILES



           None.
    


## ENVIRONMENT VARIABLES



           The following environment variables shall affect the execution of
           _tee_ :
    
           _LANG_      Provide a default value for the internationalization
                     variables that are unset or null. (See the Base
                     Definitions volume of POSIX.1‐2017, _Section 8.2_ ,
                     _Internationalization Variables_ for the precedence of
                     internationalization variables used to determine the
                     values of locale categories.)
    
           _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-byte as opposed to multi-byte characters in
                     arguments).
    
           _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_.
    


## ASYNCHRONOUS EVENTS



           Default, except that if the **-i** option was specified, SIGINT shall
           be ignored.
    


## STDOUT



           The standard output shall be a copy of the standard input.
    


## STDERR



           The standard error shall be used only for diagnostic messages.
    


## OUTPUT FILES



           If any _file_ operands are specified, the standard input shall be
           copied to each named file.
    


## EXTENDED DESCRIPTION



           None.
    


## EXIT STATUS



           The following exit values shall be returned:
    
            0    The standard input was successfully copied to all output
                 files.
    
           >0    An error occurred.
    


## CONSEQUENCES OF ERRORS



           If a write to any successfully opened _file_ operand fails, writes
           to other successfully opened _file_ operands and standard output
           shall continue, but the exit status shall be non-zero. Otherwise,
           the default actions specified in _Section 1.4_ , _Utility Description_
           _Defaults_ apply.
    
           _The following sections are informative._
    


## APPLICATION USAGE



           The _tee_ utility is usually used in a pipeline, to make a copy of
           the output of some utility.
    
           The _file_ operand is technically optional, but _tee_ is no more
           useful than _cat_ when none is specified.
    


## EXAMPLES



           Save an unsorted intermediate form of the data in a pipeline:
    
               ... | tee unsorted | sort > sorted
    


## RATIONALE



           The buffering requirement means that _tee_ is not allowed to use
           ISO C standard fully buffered or line-buffered writes. It does not
           mean that _tee_ has to do 1-byte reads followed by 1-byte writes.
    
           It should be noted that early versions of BSD ignore any invalid
           options and accept a single **'-'** as an alternative to **-i**.  They
           also print a message if unable to open a file:
    
               "tee: cannot access %s\n", <_pathname_ >
    
           Historical implementations ignore write errors. This is explicitly
           not permitted by this volume of POSIX.1‐2017.
    
           Some historical implementations use O_APPEND when providing append
           mode; others use the _lseek_() function to seek to the end-of-file
           after opening the file without O_APPEND. This volume of
           POSIX.1‐2017 requires functionality equivalent to using O_APPEND;
           see _Section 1.1.1.4_ , _File Read_ , _Write_ , _and Creation_.
    


## FUTURE DIRECTIONS



           None.
    


* * *