COMM(1)                    POSIX Programmer's Manual                   COMM(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
       comm -- select or reject lines common to two files

SSYYNNOOPPSSIISS
       comm [[-123]] _f_i_l_e_1 _f_i_l_e_2

DDEESSCCRRIIPPTTIIOONN
       The _c_o_m_m utility shall read _f_i_l_e_1 and _f_i_l_e_2, which should be ordered in
       the current collating sequence, and produce three text columns as
       output: lines only in _f_i_l_e_1, lines only in _f_i_l_e_2, and lines in both
       files.

       If the lines in both files are not ordered according to the collating
       sequence of the current locale, the results are unspecified.

OOPPTTIIOONNSS
       The _c_o_m_m 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 options shall be supported:

       --11        Suppress the output column of lines unique to _f_i_l_e_1.

       --22        Suppress the output column of lines unique to _f_i_l_e_2.

       --33        Suppress the output column of lines duplicated in _f_i_l_e_1 and
                 _f_i_l_e_2.

OOPPEERRAANNDDSS
       The following operands shall be supported:

       _f_i_l_e_1     A pathname of the first file to be compared. If _f_i_l_e_1 is ''--'',
                 the standard input shall be used.

       _f_i_l_e_2     A pathname of the second file to be compared. If _f_i_l_e_2 is
                 ''--'', the standard input shall be used.

       If both _f_i_l_e_1 and _f_i_l_e_2 refer to standard input or to the same FIFO
       special, block special, or character special file, the results are
       undefined.

SSTTDDIINN
       The standard input shall be used only if one of the _f_i_l_e_1 or _f_i_l_e_2
       operands refers to standard input. See the INPUT FILES section.

IINNPPUUTT FFIILLEESS
       The input files shall be text files.

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

       _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_O_L_L_A_T_E
                 Determine the locale for the collating sequence _c_o_m_m expects
                 to have been used when the input files were sorted.

       _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 and input
                 files).

       _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 _c_o_m_m utility shall produce output depending on the options
       selected. If the --11, --22, and --33 options are all selected, _c_o_m_m shall
       write nothing to standard output.

       If the --11 option is not selected, lines contained only in _f_i_l_e_1 shall
       be written using the format:

           ""%%ss\\nn"",, <<_l_i_n_e _i_n _f_i_l_e_1>

       If the --22 option is not selected, lines contained only in _f_i_l_e_2 are
       written using the format:

           ""%%ss%%ss\\nn"",, <<_l_e_a_d>, <_l_i_n_e _i_n _f_i_l_e_2>

       where the string <_l_e_a_d> is as follows:

       <tab>     The --11 option is not selected.

       null string
                 The --11 option is selected.

       If the --33 option is not selected, lines contained in both files shall
       be written using the format:

           ""%%ss%%ss\\nn"",, <<_l_e_a_d>, <_l_i_n_e _i_n _b_o_t_h>

       where the string <_l_e_a_d> is as follows:

       <tab><tab>
                 Neither the --11 nor the --22 option is selected.

       <tab>     Exactly one of the --11 and --22 options is selected.

       null string
                 Both the --11 and --22 options are selected.

       If the input files were ordered according to the collating sequence of
       the current locale, the lines written shall be in the collating
       sequence of the original lines.

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 successfully output as specified.

       >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
       If the input files are not properly presorted, the output of _c_o_m_m might
       not be useful.

EEXXAAMMPPLLEESS
       If a file named xxccuu contains a sorted list of the utilities in this
       volume of POSIX.1-2008, a file named xxppgg33 contains a sorted list of the
       utilities specified in the X/Open Portability Guide, Issue 3, and a
       file named ssvviidd8899 contains a sorted list of the utilities in the System
       V Interface Definition Third Edition:

           ccoommmm --2233 xxccuu xxppgg33 || ccoommmm --2233 -- ssvviidd8899

       would print a list of utilities in this volume of POSIX.1-2008 not
       specified by either of the other documents:

           ccoommmm --1122 xxccuu xxppgg33 || ccoommmm --1122 -- ssvviidd8899

       would print a list of utilities specified by all three documents, and:

           ccoommmm --1122 xxppgg33 ssvviidd8899 || ccoommmm --2233 -- xxccuu

       would print a list of utilities specified by both XPG3 and the SVID,
       but not specified in this volume of POSIX.1-2008.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _c_m_p, _d_i_f_f, _s_o_r_t, _u_n_i_q

       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

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                              COMM(1)
