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