CAT(1)                     POSIX Programmer's Manual                    CAT(1)



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


NNAAMMEE
       cat -- concatenate and print files

SSYYNNOOPPSSIISS
       cat [[-u]] [[_f_i_l_e...]]

DDEESSCCRRIIPPTTIIOONN
       The _c_a_t utility shall read files in sequence and shall write their
       contents to the standard output in the same sequence.

OOPPTTIIOONNSS
       The _c_a_t utility shall conform to the Base Definitions volume of
       POSIX.1-2008, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s.

       The following option shall be supported:

       --uu        Write bytes from the input file to the standard output
                 without delay as each is read.

OOPPEERRAANNDDSS
       The following operand shall be supported:

       _f_i_l_e      A pathname of an input file. If no _f_i_l_e operands are
                 specified, the standard input shall be used. If a _f_i_l_e is
                 ''--'', the _c_a_t utility shall read from the standard input at
                 that point in the sequence. The _c_a_t utility shall not close
                 and reopen standard input when it is referenced in this way,
                 but shall accept multiple occurrences of ''--'' as a _f_i_l_e
                 operand.

SSTTDDIINN
       The standard input shall be used only if no _f_i_l_e operands are
       specified, or if a _f_i_l_e operand is ''--''.  See the INPUT FILES section.

IINNPPUUTT FFIILLEESS
       The input files can be any file type.

EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
       The following environment variables shall affect the execution of _c_a_t:

       _L_A_N_G      Provide a default value for the internationalization
                 variables that are unset or null. (See the Base Definitions
                 volume of POSIX.1-2008, _S_e_c_t_i_o_n _8_._2, _I_n_t_e_r_n_a_t_i_o_n_a_l_i_z_a_t_i_o_n
                 _V_a_r_i_a_b_l_e_s for the precedence of internationalization
                 variables used to determine the values of locale categories.)

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

       _L_C___C_T_Y_P_E  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).

       _L_C___M_E_S_S_A_G_E_S
                 Determine the locale that should be used to affect the format
                 and contents of diagnostic messages written to standard
                 error.

       _N_L_S_P_A_T_H   Determine the location of message catalogs for the processing
                 of _L_C___M_E_S_S_A_G_E_S.

AASSYYNNCCHHRROONNOOUUSS EEVVEENNTTSS
       Default.

SSTTDDOOUUTT
       The standard output shall contain the sequence of bytes read from the
       input files. Nothing else shall be written to the standard output.

SSTTDDEERRRR
       The standard error shall be used only for diagnostic messages.

OOUUTTPPUUTT FFIILLEESS
       None.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
       The following exit values shall be returned:

        0    All input files were output successfully.

       >0    An error occurred.

CCOONNSSEEQQUUEENNCCEESS OOFF EERRRROORRSS
       Default.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       The --uu option has value in prototyping non-blocking reads from FIFOs.
       The intent is to support the following sequence:

           mmkkffiiffoo ffoooo
           ccaatt --uu ffoooo >> //ddeevv//ttttyy1133 &&
           ccaatt --uu >> ffoooo

       It is unspecified whether standard output is or is not buffered in the
       default case. This is sometimes of interest when standard output is
       associated with a terminal, since buffering may delay the output. The
       presence of the --uu option guarantees that unbuffered I/O is available.
       It is implementation-defined whether the _c_a_t utility buffers output if
       the --uu option is not specified. Traditionally, the --uu option is
       implemented using the equivalent of the _s_e_t_v_b_u_f() function defined in
       the System Interfaces volume of POSIX.1-2008.

EEXXAAMMPPLLEESS
       The following command:

           ccaatt mmyyffiillee

       writes the contents of the file mmyyffiillee to standard output.

       The following command:

           ccaatt ddoocc11 ddoocc22 >> ddoocc..aallll

       concatenates the files ddoocc11 and ddoocc22 and writes the result to ddoocc..aallll.

       Because of the shell language mechanism used to perform output
       redirection, a command such as this:

           ccaatt ddoocc ddoocc..eenndd >> ddoocc

       causes the original data in ddoocc to be lost.

       The command:

           ccaatt ssttaarrtt -- mmiiddddllee -- eenndd >> ffiillee

       when standard input is a terminal, gets two arbitrary pieces of input
       from the terminal with a single invocation of _c_a_t.  Note, however, that
       if standard input is a regular file, this would be equivalent to the
       command:

           ccaatt ssttaarrtt -- mmiiddddllee //ddeevv//nnuullll eenndd >> ffiillee

       because the entire contents of the file would be consumed by _c_a_t the
       first time ''--'' was used as a _f_i_l_e operand and an end-of-file condition
       would be detected immediately when ''--'' was referenced the second time.

RRAATTIIOONNAALLEE
       Historical versions of the _c_a_t utility include the --ee, --tt, and --vv,
       options which permit the ends of lines, <tab> characters, and invisible
       characters, respectively, to be rendered visible in the output. The
       standard developers omitted these options because they provide too fine
       a degree of control over what is made visible, and similar output can
       be obtained using a command such as:

           sseedd --nn ll ppaatthhnnaammee

       The latter also has the advantage that its output is unambiguous,
       whereas the output of historical _c_a_t --eettvv is not.

       The --ss option was omitted because it corresponds to different functions
       in BSD and System V-based systems. The BSD --ss option to squeeze blank
       lines can be accomplished by the shell script shown in the following
       example:

           sseedd --nn ''
           ## WWrriittee nnoonn--eemmppttyy lliinneess..
           //..//   {{
                 pp
                 dd
                 }}
           ## WWrriittee aa ssiinnggllee eemmppttyy lliinnee,, tthheenn llooookk ffoorr mmoorree eemmppttyy lliinneess..
           //^^$$//  pp
           ## GGeett nneexxtt lliinnee,, ddiissccaarrdd tthhee hheelldd <<nneewwlliinnee>> ((eemmppttyy lliinnee)),,
           ## aanndd llooookk ffoorr mmoorree eemmppttyy lliinneess..
           ::EEmmppttyy
           //^^$$//  {{
                 NN
                 ss//..////
                 bb EEmmppttyy
                 }}
           ## WWrriittee tthhee nnoonn--eemmppttyy lliinnee bbeeffoorree ggooiinngg bbaacckk ttoo sseeaarrcchh
           ## ffoorr tthhee ffiirrsstt iinn aa sseett ooff eemmppttyy lliinneess..
                 pp
           ''

       The System V --ss option to silence error messages can be accomplished by
       redirecting the standard error. Note that the BSD documentation for _c_a_t
       uses the term ``blank line'' to mean the same as the POSIX ``empty
       line'': a line consisting only of a <newline>.

       The BSD --nn option was omitted because similar functionality can be
       obtained from the --nn option of the _p_r utility.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _m_o_r_e

       The Base Definitions volume of POSIX.1-2008, _C_h_a_p_t_e_r _8, _E_n_v_i_r_o_n_m_e_n_t
       _V_a_r_i_a_b_l_e_s, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s

       The System Interfaces volume of POSIX.1-2008, _s_e_t_v_b_u_f()

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                               CAT(1)
