1 .\"
   2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
   3 .\" permission to reproduce portions of its copyrighted documentation.
   4 .\" Original documentation from The Open Group can be obtained online at
   5 .\" http://www.opengroup.org/bookstore/.
   6 .\"
   7 .\" The Institute of Electrical and Electronics Engineers and The Open
   8 .\" Group, have given us permission to reprint portions of their
   9 .\" documentation.
  10 .\"
  11 .\" In the following statement, the phrase ``this text'' refers to portions
  12 .\" of the system documentation.
  13 .\"
  14 .\" Portions of this text are reprinted and reproduced in electronic form
  15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
  16 .\" Standard for Information Technology -- Portable Operating System
  17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
  18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
  19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
  20 .\" between these versions and the original IEEE and The Open Group
  21 .\" Standard, the original IEEE and The Open Group Standard is the referee
  22 .\" document.  The original Standard can be obtained online at
  23 .\" http://www.opengroup.org/unix/online.html.
  24 .\"
  25 .\" This notice shall appear on any product containing this material.
  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)