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 .\" 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