26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
45 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
46 .\"
47 .TH COMM 1 "Mar 3, 2004"
48 .SH NAME
49 comm \- select or reject lines common to two files
50 .SH SYNOPSIS
51 .LP
52 .nf
53 \fBcomm\fR [\fB-123\fR] \fIfile1\fR \fIfile2\fR
54 .fi
55
56 .SH DESCRIPTION
57 .sp
58 .LP
59 The \fBcomm\fR utility reads \fIfile1\fR and \fIfile2\fR, which must be ordered
60 in the current collating sequence, and produces three text columns as output:
61 lines only in \fIfile1\fR; lines only in \fIfile2\fR; and lines in both files.
62 .sp
63 .LP
64 If the input files were ordered according to the collating sequence of the
65 current locale, the lines written will be in the collating sequence of the
66 original lines. If not, the results are unspecified.
67 .SH OPTIONS
68 .sp
69 .LP
70 The following options are supported:
71 .sp
72 .ne 2
73 .na
74 \fB\fB-1\fR\fR
75 .ad
76 .RS 6n
77 Suppresses the output column of lines unique to \fIfile1\fR.
78 .RE
79
80 .sp
81 .ne 2
82 .na
83 \fB\fB-2\fR\fR
84 .ad
85 .RS 6n
86 Suppresses the output column of lines unique to \fIfile2\fR.
87 .RE
88
89 .sp
90 .ne 2
91 .na
92 \fB\fB-3\fR\fR
93 .ad
94 .RS 6n
95 Suppresses the output column of lines duplicated in \fIfile1\fR and
96 \fIfile2\fR.
97 .RE
98
99 .SH OPERANDS
100 .sp
101 .LP
102 The following operands are supported:
103 .sp
104 .ne 2
105 .na
106 \fB\fIfile1\fR\fR
107 .ad
108 .RS 9n
109 A path name of the first file to be compared. If \fIfile1\fR is \fB\(mi\fR, the
110 standard input is used.
111 .RE
112
113 .sp
114 .ne 2
115 .na
116 \fB\fIfile2\fR\fR
117 .ad
118 .RS 9n
119 A path name of the second file to be compared. If \fIfile2\fR is \fB\(mi\fR,
120 the standard input is used.
121 .RE
122
123 .SH USAGE
124 .sp
125 .LP
126 See \fBlargefile\fR(5) for the description of the behavior of \fBcomm\fR when
127 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
128 .SH EXAMPLES
129 .LP
130 \fBExample 1 \fRPrinting a list of utilities specified by files
131 .sp
132 .LP
133 If \fIfile1\fR, \fIfile2\fR, and \fIfile3\fR each contain a sorted list of
134 utilities, the command
135
136 .sp
137 .in +2
138 .nf
139 example% \fBcomm -23 file1 file2 | comm -23 - file3\fR
140 .fi
141 .in -2
142 .sp
143
144 .sp
145 .LP
146 prints a list of utilities in \fIfile1\fR not specified by either of the other
147 files. The entry:
148
149 .sp
150 .in +2
151 .nf
152 example% \fBcomm -12 file1 file2 | comm -12 - file3\fR
153 .fi
154 .in -2
155 .sp
156
157 .sp
158 .LP
159 prints a list of utilities specified by all three files. And the entry:
160
161 .sp
162 .in +2
163 .nf
164 example% \fBcomm -12 file2 file3 | comm -23 -file1\fR
165 .fi
166 .in -2
167 .sp
168
169 .sp
170 .LP
171 prints a list of utilities specified by both \fIfile2\fR and \fIfile3\fR, but
172 not specified in \fIfile1\fR.
173
174 .SH ENVIRONMENT VARIABLES
175 .sp
176 .LP
177 See \fBenviron\fR(5) for descriptions of the following environment variables
178 that affect the execution of \fBcomm\fR: \fBLANG\fR, \fBLC_ALL\fR,
179 \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
180 .SH EXIT STATUS
181 .sp
182 .LP
183 The following exit values are returned:
184 .sp
185 .ne 2
186 .na
187 \fB\fB0\fR\fR
188 .ad
189 .RS 6n
190 All input files were successfully output as specified.
191 .RE
192
193 .sp
194 .ne 2
195 .na
196 \fB\fB>0\fR\fR
197 .ad
198 .RS 6n
199 An error occurred.
200 .RE
201
202 .SH ATTRIBUTES
203 .sp
204 .LP
205 See \fBattributes\fR(5) for descriptions of the following attributes:
206 .sp
207
208 .sp
209 .TS
210 box;
211 c | c
212 l | l .
213 ATTRIBUTE TYPE ATTRIBUTE VALUE
214 _
215 CSI enabled
216 _
217 Interface Stability Standard
218 .TE
219
220 .SH SEE ALSO
221 .sp
222 .LP
223 \fBcmp\fR(1), \fBdiff\fR(1), \fBsort\fR(1), \fBuniq\fR(1), \fBattributes\fR(5),
224 \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)
|
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
45 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
46 .\" Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
47 .Dd Feb 9, 2021
48 .Dt COMM 1
49 .Os
50 .Sh NAME
51 .Nm comm
52 .Nd select or reject lines common to two files
53 .Sh SYNOPSIS
54 .Nm
55 .Op Fl 123
56 .Ar file1 file2
57 .Sh DESCRIPTION
58 The
59 .Nm
60 utility reads
61 .Ar file1
62 and
63 .Ar file2 ,
64 which must be ordered in the current collating sequence, and produces three
65 text columns as output:
66 .Bl -bullet -offset Ds
67 .It
68 lines only in
69 .Ar file1 ;
70 .It
71 lines only in
72 .Ar file2 ;
73 .It
74 lines in both files.
75 .El
76 .Pp
77 If the input files were ordered according to the collating sequence of the
78 current locale, the lines written will be in the collating sequence of the
79 original lines.
80 If not, the results are unspecified.
81 .Pp
82 If either
83 .Ar file1
84 or
85 .Ar file2
86 is
87 .Ar \(mi ,
88 .Nm
89 uses standard input starting at the current location.
90 .Sh OPTIONS
91 The following options are supported:
92 .Bl -tag -width Ar
93 .It Fl 1
94 Suppresses the output column of lines unique to
95 .Ar file1 .
96 .It Fl 2
97 Suppresses the output column of lines unique to
98 .Ar file2 .
99 .It Fl 3
100 Suppresses the output column of lines common to both
101 .Ar file1
102 and
103 .Ar file2 .
104 .El
105 .Sh OPERANDS
106 The following operands are supported:
107 .Bl -tag -width Ar
108 .It Ar file1
109 A path name of the first file to be compared.
110 If
111 .Ar file1
112 is
113 .Em \(mi ,
114 the standard input is used.
115 .It Ar file2
116 A path name of the second file to be compared.
117 If
118 .Ar file1
119 is
120 .Em \(mi ,
121 the standard input is used.
122 .El
123 .Sh EXIT STATUS
124 The following exit values are returned:
125 .Bl -tag -width Ds
126 .It Sy 0
127 All input files were successfully output as specified.
128 .It Sy >0
129 An error occurred.
130 .El
131 .Sh EXAMPLES
132 .Bl -tag -width 6
133 .It Sy Example 1 No Printing a list of utilities specified by files
134 .Pp
135 If
136 .Ar file1 ,
137 .Ar file2 ,
138 and
139 .Ar file3
140 each contain a sorted list of utilities, the command
141 .Bd -literal
142 $ comm -23 file1 file2 | comm -23 - file3
143 .Ed
144 .Pp
145 prints a list of utilities in
146 .Ar file1
147 not specified by either of the other files.
148 .Pp
149 The command:
150 .Bd -literal
151 $ comm -12 file1 file2 | comm -12 - file3
152 .Ed
153 .Pp
154 prints a list of utilities specified by all three files; and the command:
155 .Bd -literal
156 $ comm -12 file2 file3 | comm -23 -file1
157 .Ed
158 .Pp
159 prints a list of utilities specified by both
160 .Ar file2
161 and
162 .Ar file3 ,
163 but not specified in
164 .Ar file1 .
165 .El
166 .Sh ENVIRONMENT VARIABLES
167 See
168 .Xr environ 5
169 for descriptions of the following environment variables
170 that affect the execution of
171 .Nm :
172 .Ev LANG ,
173 .Ev LC_ALL ,
174 .Ev LC_COLLATE ,
175 .Ev LC_CTYPE ,
176 .Ev LC_MESSAGES ,
177 .Ev LC_NUMERIC ,
178 and
179 .Ev NLSPATH .
180 .Sh INTERFACE STABILITY
181 The command line interface of
182 .Nm
183 is
184 .Sy Committed .
185 The output of
186 .Nm
187 is
188 .Sy Committed .
189 .Sh SEE ALSO
190 .Xr cmp 1 ,
191 .Xr diff 1 ,
192 .Xr sort 1 ,
193 .Xr uniq 1 ,
194 .Xr attributes 5 ,
195 .Xr environ 5 ,
196 .Xr largefile 5 ,
197 .Xr standards 5
|