xref: /freebsd/usr.bin/comm/comm.1 (revision bdcbfde31e8e9b343f113a1956384bdf30d1ed62)
19b50d902SRodney W. Grimes.\" Copyright (c) 1989, 1990, 1993
29b50d902SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
39b50d902SRodney W. Grimes.\"
49b50d902SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
59b50d902SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc.
69b50d902SRodney W. Grimes.\"
79b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
89b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions
99b50d902SRodney W. Grimes.\" are met:
109b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
119b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
129b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
139b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
149b50d902SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
15fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
169b50d902SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
179b50d902SRodney W. Grimes.\"    without specific prior written permission.
189b50d902SRodney W. Grimes.\"
199b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
209b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
219b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
229b50d902SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
239b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
249b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
259b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
269b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
279b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
289b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
299b50d902SRodney W. Grimes.\" SUCH DAMAGE.
309b50d902SRodney W. Grimes.\"
31*bdfea496SFernando Apesteguía.Dd July 27, 2020
329b50d902SRodney W. Grimes.Dt COMM 1
33aa12cea2SUlrich Spörlein.Os
349b50d902SRodney W. Grimes.Sh NAME
359b50d902SRodney W. Grimes.Nm comm
369b50d902SRodney W. Grimes.Nd select or reject lines common to two files
379b50d902SRodney W. Grimes.Sh SYNOPSIS
388fe908efSRuslan Ermilov.Nm
392ca7dc15SJoerg Wunsch.Op Fl 123i
409b50d902SRodney W. Grimes.Ar file1 file2
419b50d902SRodney W. Grimes.Sh DESCRIPTION
429b50d902SRodney W. GrimesThe
438fe908efSRuslan Ermilov.Nm
449b50d902SRodney W. Grimesutility reads
459b50d902SRodney W. Grimes.Ar file1
469b50d902SRodney W. Grimesand
479b50d902SRodney W. Grimes.Ar file2 ,
489b50d902SRodney W. Grimeswhich should be
499b50d902SRodney W. Grimessorted lexically, and produces three text
509b50d902SRodney W. Grimescolumns as output: lines only in
519b50d902SRodney W. Grimes.Ar file1 ;
529b50d902SRodney W. Grimeslines only in
539b50d902SRodney W. Grimes.Ar file2 ;
549b50d902SRodney W. Grimesand lines in both files.
559b50d902SRodney W. Grimes.Pp
569b50d902SRodney W. GrimesThe filename ``-'' means the standard input.
579b50d902SRodney W. Grimes.Pp
589b50d902SRodney W. GrimesThe following options are available:
593a87eff1SPhilippe Charnier.Bl -tag -width indent
609b50d902SRodney W. Grimes.It Fl 1
6134b7df97SWarner LoshSuppress printing of column 1, lines only in
6234b7df97SWarner Losh.Ar file1 .
639b50d902SRodney W. Grimes.It Fl 2
6434b7df97SWarner LoshSuppress printing of column 2, lines only in
6534b7df97SWarner Losh.Ar file2 .
669b50d902SRodney W. Grimes.It Fl 3
6734b7df97SWarner LoshSuppress printing of column 3, lines common to both.
682ca7dc15SJoerg Wunsch.It Fl i
692ca7dc15SJoerg WunschCase insensitive comparison of lines.
709b50d902SRodney W. Grimes.El
719b50d902SRodney W. Grimes.Pp
729b50d902SRodney W. GrimesEach column will have a number of tab characters prepended to it
739b50d902SRodney W. Grimesequal to the number of lower numbered columns that are being printed.
749b50d902SRodney W. GrimesFor example, if column number two is being suppressed, lines printed
759b50d902SRodney W. Grimesin column number one will not have any tabs preceding them, and lines
769b50d902SRodney W. Grimesprinted in column number three will have one.
779b50d902SRodney W. Grimes.Pp
783898680cSPhilippe CharnierThe
793898680cSPhilippe Charnier.Nm
803898680cSPhilippe Charnierutility assumes that the files are lexically sorted; all characters
819b50d902SRodney W. Grimesparticipate in line comparisons.
82e9fbd31aSTim J. Robbins.Sh ENVIRONMENT
83e9fbd31aSTim J. RobbinsThe
84e9fbd31aSTim J. Robbins.Ev LANG ,
85e9fbd31aSTim J. Robbins.Ev LC_ALL ,
86e9fbd31aSTim J. Robbins.Ev LC_COLLATE ,
87e9fbd31aSTim J. Robbinsand
88e9fbd31aSTim J. Robbins.Ev LC_CTYPE
89e9fbd31aSTim J. Robbinsenvironment variables affect the execution of
90e9fbd31aSTim J. Robbins.Nm
91e9fbd31aSTim J. Robbinsas described in
92e9fbd31aSTim J. Robbins.Xr environ 7 .
93a866e170SRuslan Ermilov.Sh EXIT STATUS
94d628d776SRuslan Ermilov.Ex -std
95*bdfea496SFernando Apesteguía.Sh EXAMPLES
96*bdfea496SFernando ApesteguíaAssuming a file named
97*bdfea496SFernando Apesteguía.Pa example.txt
98*bdfea496SFernando Apesteguíawith the following contents:
99*bdfea496SFernando Apesteguía.Bd -literal -offset indent
100*bdfea496SFernando Apesteguíaa
101*bdfea496SFernando Apesteguíab
102*bdfea496SFernando Apesteguíac
103*bdfea496SFernando Apesteguíad
104*bdfea496SFernando Apesteguía.Ed
105*bdfea496SFernando Apesteguía.Pp
106*bdfea496SFernando ApesteguíaShow lines only in
107*bdfea496SFernando Apesteguía.Pa example.txt ,
108*bdfea496SFernando Apesteguíalines only in stdin and common lines:
109*bdfea496SFernando Apesteguía.Bd -literal -offset indent
110*bdfea496SFernando Apesteguía$ echo -e "B\enc" | comm example.txt -
111*bdfea496SFernando Apesteguía        B
112*bdfea496SFernando Apesteguíaa
113*bdfea496SFernando Apesteguíab
114*bdfea496SFernando Apesteguía                c
115*bdfea496SFernando Apesteguíad
116*bdfea496SFernando Apesteguía.Ed
117*bdfea496SFernando Apesteguía.Pp
118*bdfea496SFernando ApesteguíaShow only common lines doing case insensitive comparisons:
119*bdfea496SFernando Apesteguía.Bd -literal -offset indent
120*bdfea496SFernando Apesteguía$ echo -e "B\enc" | comm -1 -2 -i example.txt -
121*bdfea496SFernando Apesteguíab
122*bdfea496SFernando Apesteguíac
123*bdfea496SFernando Apesteguía.Ed
1249b50d902SRodney W. Grimes.Sh SEE ALSO
1259b50d902SRodney W. Grimes.Xr cmp 1 ,
1269b50d902SRodney W. Grimes.Xr diff 1 ,
1279b50d902SRodney W. Grimes.Xr sort 1 ,
1289b50d902SRodney W. Grimes.Xr uniq 1
1299b50d902SRodney W. Grimes.Sh STANDARDS
1309b50d902SRodney W. GrimesThe
1318fe908efSRuslan Ermilov.Nm
1320e25805fSPhilippe Charnierutility conforms to
1330e25805fSPhilippe Charnier.St -p1003.2-92 .
1342ac2784fSTim J. Robbins.Pp
1352ac2784fSTim J. RobbinsThe
1362ac2784fSTim J. Robbins.Fl i
137*bdfea496SFernando Apesteguíaoption is an extension to the POSIX standard.
1387c5b7514STim J. Robbins.Sh HISTORY
1397c5b7514STim J. RobbinsA
1407c5b7514STim J. Robbins.Nm
1417c5b7514STim J. Robbinscommand appeared in
1427c5b7514STim J. Robbins.At v4 .
143