1COMM(1P) POSIX Programmer's Manual COMM(1P)
2
3
4
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
12 comm - select or reject lines common to two files
13
15 comm [-123] file1 file2
16
18 The comm utility shall read file1 and file2, which should be ordered in
19 the current collating sequence, and produce three text columns as out‐
20 put: lines only in file1, lines only in file2, and lines in both files.
21
22 If the lines in both files are not ordered according to the collating
23 sequence of the current locale, the results are unspecified.
24
26 The comm utility shall conform to the Base Definitions volume of
27 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
28
29 The following options shall be supported:
30
31 -1 Suppress the output column of lines unique to file1.
32
33 -2 Suppress the output column of lines unique to file2.
34
35 -3 Suppress the output column of lines duplicated in file1 and
36 file2.
37
38
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
49 If both file1 and file2 refer to standard input or to the same FIFO
50 special, block special, or character special file, the results are
51 undefined.
52
54 The standard input shall be used only if one of the file1 or file2 op‐
55 erands refers to standard input. See the INPUT FILES section.
56
58 The input files shall be text files.
59
61 The following environment variables shall affect the execution of comm:
62
63 LANG Provide a default value for the internationalization variables
64 that are unset or null. (See the Base Definitions volume of
65 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
66 ables for the precedence of internationalization variables used
67 to determine the values of locale categories.)
68
69 LC_ALL If set to a non-empty string value, override the values of all
70 the other internationalization variables.
71
72 LC_COLLATE
73
74 Determine the locale for the collating sequence comm expects to
75 have been used when the input files were sorted.
76
77 LC_CTYPE
78 Determine the locale for the interpretation of sequences of
79 bytes of text data as characters (for example, single-byte as
80 opposed to multi-byte characters in arguments and input files).
81
82 LC_MESSAGES
83 Determine the locale that should be used to affect the format
84 and contents of diagnostic messages written to standard error.
85
86 NLSPATH
87 Determine the location of message catalogs for the processing of
88 LC_MESSAGES .
89
90
92 Default.
93
95 The comm utility shall produce output depending on the options
96 selected. If the -1, -2, and -3 options are all selected, comm shall
97 write nothing to standard output.
98
99 If the -1 option is not selected, lines contained only in file1 shall
100 be written using the format:
101
102
103 "%s\n", <line in file1>
104
105 If the -2 option is not selected, lines contained only in file2 are
106 written using the format:
107
108
109 "%s%s\n", <lead>, <line in file2>
110
111 where the string <lead> is as follows:
112
113 <tab> The -1 option is not selected.
114
115 null string
116 The -1 option is selected.
117
118
119 If the -3 option is not selected, lines contained in both files shall
120 be written using the format:
121
122
123 "%s%s\n", <lead>, <line in both>
124
125 where the string <lead> is as follows:
126
127 <tab><tab>
128 Neither the -1 nor the -2 option is selected.
129
130 <tab> Exactly one of the -1 and -2 options is selected.
131
132 null string
133 Both the -1 and -2 options are selected.
134
135
136 If the input files were ordered according to the collating sequence of
137 the current locale, the lines written shall be in the collating
138 sequence of the original lines.
139
141 The standard error shall be used only for diagnostic messages.
142
144 None.
145
147 None.
148
150 The following exit values shall be returned:
151
152 0 All input files were successfully output as specified.
153
154 >0 An error occurred.
155
156
158 Default.
159
160 The following sections are informative.
161
163 If the input files are not properly presorted, the output of comm might
164 not be useful.
165
167 If a file named xcu contains a sorted list of the utilities in this
168 volume of IEEE Std 1003.1-2001, a file named xpg3 contains a sorted
169 list of the utilities specified in the X/Open Portability Guide, Issue
170 3, and a file named svid89 contains a sorted list of the utilities in
171 the System V Interface Definition Third Edition:
172
173
174 comm -23 xcu xpg3 | comm -23 - svid89
175
176 would print a list of utilities in this volume of IEEE Std 1003.1-2001
177 not specified by either of the other documents:
178
179
180 comm -12 xcu xpg3 | comm -12 - svid89
181
182 would print a list of utilities specified by all three documents, and:
183
184
185 comm -12 xpg3 svid89 | comm -23 - xcu
186
187 would print a list of utilities specified by both XPG3 and the SVID,
188 but not specified in this volume of IEEE Std 1003.1-2001.
189
191 None.
192
194 None.
195
197 cmp, diff, sort, uniq
198
200 Portions of this text are reprinted and reproduced in electronic form
201 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
202 -- Portable Operating System Interface (POSIX), The Open Group Base
203 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
204 Electrical and Electronics Engineers, Inc and The Open Group. In the
205 event of any discrepancy between this version and the original IEEE and
206 The Open Group Standard, the original IEEE and The Open Group Standard
207 is the referee document. The original Standard can be obtained online
208 at http://www.opengroup.org/unix/online.html .
209
210
211
212IEEE/The Open Group 2003 COMM(1P)