1.\" Copyright (c) 1989, 1990, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the Institute of Electrical and Electronics Engineers, Inc. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" From: @(#)comm.1 8.1 (Berkeley) 6/6/93 32.\" 33.Dd July 27, 2020 34.Dt COMM 1 35.Os 36.Sh NAME 37.Nm comm 38.Nd select or reject lines common to two files 39.Sh SYNOPSIS 40.Nm 41.Op Fl 123i 42.Ar file1 file2 43.Sh DESCRIPTION 44The 45.Nm 46utility reads 47.Ar file1 48and 49.Ar file2 , 50which should be 51sorted lexically, and produces three text 52columns as output: lines only in 53.Ar file1 ; 54lines only in 55.Ar file2 ; 56and lines in both files. 57.Pp 58The filename ``-'' means the standard input. 59.Pp 60The following options are available: 61.Bl -tag -width indent 62.It Fl 1 63Suppress printing of column 1, lines only in 64.Ar file1 . 65.It Fl 2 66Suppress printing of column 2, lines only in 67.Ar file2 . 68.It Fl 3 69Suppress printing of column 3, lines common to both. 70.It Fl i 71Case insensitive comparison of lines. 72.El 73.Pp 74Each column will have a number of tab characters prepended to it 75equal to the number of lower numbered columns that are being printed. 76For example, if column number two is being suppressed, lines printed 77in column number one will not have any tabs preceding them, and lines 78printed in column number three will have one. 79.Pp 80The 81.Nm 82utility assumes that the files are lexically sorted; all characters 83participate in line comparisons. 84.Sh ENVIRONMENT 85The 86.Ev LANG , 87.Ev LC_ALL , 88.Ev LC_COLLATE , 89and 90.Ev LC_CTYPE 91environment variables affect the execution of 92.Nm 93as described in 94.Xr environ 7 . 95.Sh EXIT STATUS 96.Ex -std 97.Sh EXAMPLES 98Assuming a file named 99.Pa example.txt 100with the following contents: 101.Bd -literal -offset indent 102a 103b 104c 105d 106.Ed 107.Pp 108Show lines only in 109.Pa example.txt , 110lines only in stdin and common lines: 111.Bd -literal -offset indent 112$ echo -e "B\enc" | comm example.txt - 113 B 114a 115b 116 c 117d 118.Ed 119.Pp 120Show only common lines doing case insensitive comparisons: 121.Bd -literal -offset indent 122$ echo -e "B\enc" | comm -1 -2 -i example.txt - 123b 124c 125.Ed 126.Sh SEE ALSO 127.Xr cmp 1 , 128.Xr diff 1 , 129.Xr sort 1 , 130.Xr uniq 1 131.Sh STANDARDS 132The 133.Nm 134utility conforms to 135.St -p1003.2-92 . 136.Pp 137The 138.Fl i 139option is an extension to the POSIX standard. 140.Sh HISTORY 141A 142.Nm 143command appeared in 144.At v4 . 145