]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/comm/comm.1
nvi: import version 2.2.1
[FreeBSD/FreeBSD.git] / usr.bin / comm / comm.1
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
44 The
45 .Nm
46 utility reads
47 .Ar file1
48 and
49 .Ar file2 ,
50 which should be
51 sorted lexically, and produces three text
52 columns as output: lines only in
53 .Ar file1 ;
54 lines only in
55 .Ar file2 ;
56 and lines in both files.
57 .Pp
58 The filename ``-'' means the standard input.
59 .Pp
60 The following options are available:
61 .Bl -tag -width indent
62 .It Fl 1
63 Suppress printing of column 1, lines only in
64 .Ar file1 .
65 .It Fl 2
66 Suppress printing of column 2, lines only in
67 .Ar file2 .
68 .It Fl 3
69 Suppress printing of column 3, lines common to both.
70 .It Fl i
71 Case insensitive comparison of lines.
72 .El
73 .Pp
74 Each column will have a number of tab characters prepended to it
75 equal to the number of lower numbered columns that are being printed.
76 For example, if column number two is being suppressed, lines printed
77 in column number one will not have any tabs preceding them, and lines
78 printed in column number three will have one.
79 .Pp
80 The
81 .Nm
82 utility assumes that the files are lexically sorted; all characters
83 participate in line comparisons.
84 .Sh ENVIRONMENT
85 The
86 .Ev LANG ,
87 .Ev LC_ALL ,
88 .Ev LC_COLLATE ,
89 and
90 .Ev LC_CTYPE
91 environment variables affect the execution of
92 .Nm
93 as described in
94 .Xr environ 7 .
95 .Sh EXIT STATUS
96 .Ex -std
97 .Sh EXAMPLES
98 Assuming a file named
99 .Pa example.txt
100 with the following contents:
101 .Bd -literal -offset indent
102 a
103 b
104 c
105 d
106 .Ed
107 .Pp
108 Show lines only in
109 .Pa example.txt ,
110 lines only in stdin and common lines:
111 .Bd -literal -offset indent
112 $ echo -e "B\enc" | comm example.txt -
113         B
114 a
115 b
116                 c
117 d
118 .Ed
119 .Pp
120 Show only common lines doing case insensitive comparisons:
121 .Bd -literal -offset indent
122 $ echo -e "B\enc" | comm -1 -2 -i example.txt -
123 b
124 c
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
132 The
133 .Nm
134 utility conforms to
135 .St -p1003.2-92 .
136 .Pp
137 The
138 .Fl i
139 option is an extension to the POSIX standard.
140 .Sh HISTORY
141 A
142 .Nm
143 command appeared in
144 .At v4 .