1COMM(1P)                   POSIX Programmer's Manual                  COMM(1P)
2
3
4

PROLOG

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

NAME

13       comm — select or reject lines common to two files
14

SYNOPSIS

16       comm [−123] file1 file2
17

DESCRIPTION

19       The comm utility shall read file1 and file2, which should be ordered in
20       the  current collating sequence, and produce three text columns as out‐
21       put: lines only in file1, lines only in file2, and lines in both files.
22
23       If the lines in both files are not ordered according to  the  collating
24       sequence of the current locale, the results are unspecified.
25

OPTIONS

27       The  comm  utility  shall  conform  to  the  Base Definitions volume of
28       POSIX.1‐2008, Section 12.2, Utility Syntax Guidelines.
29
30       The following options shall be supported:
31
32       −1        Suppress the output column of lines unique to file1.
33
34       −2        Suppress the output column of lines unique to file2.
35
36       −3        Suppress the output column of lines duplicated in  file1  and
37                 file2.
38

OPERANDS

40       The following operands shall be supported:
41
42       file1     A pathname of the first file to be compared. If file1 is '−',
43                 the standard input shall be used.
44
45       file2     A pathname of the second file to be  compared.  If  file2  is
46                 '−', the standard input shall be used.
47
48       If  both  file1  and  file2 refer to standard input or to the same FIFO
49       special, block special, or character  special  file,  the  results  are
50       undefined.
51

STDIN

53       The  standard input shall be used only if one of the file1 or file2 op‐
54       erands refers to standard input. See the INPUT FILES section.
55

INPUT FILES

57       The input files shall be text files.
58

ENVIRONMENT VARIABLES

60       The following environment variables shall affect the execution of comm:
61
62       LANG      Provide a default value for  the  internationalization  vari‐
63                 ables  that are unset or null. (See the Base Definitions vol‐
64                 ume of POSIX.1‐2008, Section 8.2, Internationalization  Vari‐
65                 ables  for  the  precedence of internationalization variables
66                 used to determine the values of locale categories.)
67
68       LC_ALL    If set to a non-empty string value, override  the  values  of
69                 all the other internationalization variables.
70
71       LC_COLLATE
72                 Determine  the locale for the collating sequence comm expects
73                 to have been used when the input files were sorted.
74
75       LC_CTYPE  Determine the locale for the interpretation of  sequences  of
76                 bytes of text data as characters (for example, single-byte as
77                 opposed to  multi-byte  characters  in  arguments  and  input
78                 files).
79
80       LC_MESSAGES
81                 Determine the locale that should be used to affect the format
82                 and contents  of  diagnostic  messages  written  to  standard
83                 error.
84
85       NLSPATH   Determine the location of message catalogs for the processing
86                 of LC_MESSAGES.
87

ASYNCHRONOUS EVENTS

89       Default.
90

STDOUT

92       The  comm  utility  shall  produce  output  depending  on  the  options
93       selected.  If  the  −1, −2, and −3 options are all selected, comm shall
94       write nothing to standard output.
95
96       If the −1 option is not selected, lines contained only in  file1  shall
97       be written using the format:
98
99           "%s\n", <line in file1>
100
101       If  the  −2  option  is not selected, lines contained only in file2 are
102       written using the format:
103
104           "%s%s\n", <lead>, <line in file2>
105
106       where the string <lead> is as follows:
107
108       <tab>     The −1 option is not selected.
109
110       null string
111                 The −1 option is selected.
112
113       If the −3 option is not selected, lines contained in both  files  shall
114       be written using the format:
115
116           "%s%s\n", <lead>, <line in both>
117
118       where the string <lead> is as follows:
119
120       <tab><tab>
121                 Neither the −1 nor the −2 option is selected.
122
123       <tab>     Exactly one of the −1 and −2 options is selected.
124
125       null string
126                 Both the −1 and −2 options are selected.
127
128       If  the input files were ordered according to the collating sequence of
129       the current locale,  the  lines  written  shall  be  in  the  collating
130       sequence of the original lines.
131

STDERR

133       The standard error shall be used only for diagnostic messages.
134

OUTPUT FILES

136       None.
137

EXTENDED DESCRIPTION

139       None.
140

EXIT STATUS

142       The following exit values shall be returned:
143
144        0    All input files were successfully output as specified.
145
146       >0    An error occurred.
147

CONSEQUENCES OF ERRORS

149       Default.
150
151       The following sections are informative.
152

APPLICATION USAGE

154       If the input files are not properly presorted, the output of comm might
155       not be useful.
156

EXAMPLES

158       If a file named xcu contains a sorted list of  the  utilities  in  this
159       volume of POSIX.1‐2008, a file named xpg3 contains a sorted list of the
160       utilities specified in the X/Open Portability Guide,  Issue  3,  and  a
161       file named svid89 contains a sorted list of the utilities in the System
162       V Interface Definition Third Edition:
163
164           comm −23 xcu xpg3 | comm −23 − svid89
165
166       would print a list of utilities in  this  volume  of  POSIX.1‐2008  not
167       specified by either of the other documents:
168
169           comm −12 xcu xpg3 | comm −12 − svid89
170
171       would print a list of utilities specified by all three documents, and:
172
173           comm −12 xpg3 svid89 | comm −23 − xcu
174
175       would  print  a  list of utilities specified by both XPG3 and the SVID,
176       but not specified in this volume of POSIX.1‐2008.
177

RATIONALE

179       None.
180

FUTURE DIRECTIONS

182       None.
183

SEE ALSO

185       cmp, diff, sort, uniq
186
187       The Base Definitions volume of  POSIX.1‐2008,  Chapter  8,  Environment
188       Variables, Section 12.2, Utility Syntax Guidelines
189
191       Portions  of  this text are reprinted and reproduced in electronic form
192       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
193       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
194       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
195       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
196       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
197       event of any discrepancy between this version and the original IEEE and
198       The Open Group Standard, the original IEEE and The Open Group  Standard
199       is  the  referee document. The original Standard can be obtained online
200       at http://www.unix.org/online.html .
201
202       Any typographical or formatting errors that appear  in  this  page  are
203       most likely to have been introduced during the conversion of the source
204       files to man page format. To report such errors,  see  https://www.ker
205       nel.org/doc/man-pages/reporting_bugs.html .
206
207
208
209IEEE/The Open Group                  2013                             COMM(1P)
Impressum