xref: /csrg-svn/usr.bin/cmp/cmp.1 (revision 43082)
1*43082Scael.\" Copyright (c) 1987, 1990 The Regents of the University of California.
2*43082Scael.\" All rights reserved.
319387Smckusick.\"
4*43082Scael.\" %sccs.include.redist.man%
532644Sbostic.\"
6*43082Scael.\"     @(#)cmp.1	6.3 (Berkeley) 06/11/90
7*43082Scael.\"
8*43082Scael.Dd
9*43082Scael.Dt CMP 1
10*43082Scael.Os BSD 4.4
11*43082Scael.Sh NAME
12*43082Scael.Nm cmp
13*43082Scael.Nd compare two files
14*43082Scael.Sh SYNOPSIS
15*43082Scael.Nm cmp
16*43082Scael.Op Fl l Fl s
17*43082Scael.Ar file1 file2
18*43082Scael.Sh DESCRIPTION
19*43082ScaelThe cmp utility compares two files.
20*43082ScaelUnder default options,
21*43082Scaelcmp writes no output if the files are the same; if they
22*43082Scaeldiffer, it writes to standard output the byte and line
23*43082Scaelnumber at which the first difference occurred.
24*43082ScaelBytes and
25*43082Scaellines are numbered beginning with one.
26*43082Scael.Pp
27*43082ScaelThe following options are available:
28*43082Scael.Tp Fl l
29*43082ScaelPrint the byte number (decimal) and the differing
30*43082Scaelbytes (octal) for each difference.
31*43082Scael.Tp Fl s
32*43082ScaelPrint nothing for differing files; return exit
33*43082Scaelstatus only.
34*43082Scael.Tp
35*43082Scael.Pp
36*43082ScaelNothing is guaranteed if both
37*43082Scael.Fl s
38*43082Scaeland
39*43082Scael.Fl l
40*43082Scaelare given.
41*43082Scael.Pp
42*43082ScaelThe following operands are available:
43*43082Scael.Tw file1
44*43082Scael.Tp Ar file1
45*43082ScaelA pathname of the first file to be compared.
46*43082ScaelIf
47*43082Scael.Ar file1
48*43082Scaelis
49*43082Scael.Cx Fl
50*43082Scael.Cx ,
51*43082Scael.Cx
52*43082Scaelthe standard input is used.
53*43082Scael.Tp Ar file2
54*43082ScaelA pathname of the second file to be compared.
55*43082Scael.Tp
56*43082Scael.Pp
57*43082ScaelThe input files can be any file type.
58*43082Scael.Pp
59*43082ScaelResults of the comparison are written to standard output.
60*43082ScaelWhen no options are used, the format is:
61*43082Scael.Pp
62*43082Scael.Ds I
63*43082Scael"%s %s differ: char %d, line %d\en", <file1>,
64*43082Scael<file2>, <byte number>, <line number>
65*43082Scael.De
66*43082Scael.Pp
67*43082ScaelWhen the
68*43082Scael.Fl l
69*43082Scaeloption is used, the format is:
70*43082Scael.Pp
71*43082Scael.Ds I
72*43082Scael"%d %o %o\en", <byte number>, <differing byte>,
73*43082Scael<differing byte>
74*43082Scael.De
75*43082Scael.Pp
76*43082Scaelfor each byte that differs.  The first byte number is from
77*43082Scaelfile1 while the second is from file2.
78*43082Scael.Pp
79*43082ScaelIf file1 and file2 are identical for the entire length of
80*43082Scaelthe shorter file, the following format is used, unless the
81*43082Scael.Fl s
82*43082Scaeloption is specified.
83*43082Scael.Pp
84*43082Scael.Ds I
85*43082Scael"cmp: EOF on %s\en", <name of shorter file>
86*43082Scael.De
87*43082Scael.Pp
88*43082ScaelNo output is written to standard output when the
89*43082Scael.Fl s option
90*43082Scaelis used.
91*43082Scael.Pp
92*43082ScaelThe
93*43082Scael.Nm cmp
94*43082Scaelutility exits with one of the following values:
95*43082Scael.Tw Fl
96*43082Scael.Tp 0
97*43082ScaelThe files are identical.
98*43082Scael.Tp 1
99*43082ScaelThe files are different; this includes the case
100*43082Scaelwhere one file is identical to the first part of
101*43082Scaelthe other.
102*43082ScaelIn the latter case, if the -s option has
103*43082Scaelnot been specified, cmp writes to standard error
104*43082Scaelthat EOF was reached in the shorter file (before
105*43082Scaelany differences were found).
106*43082Scael.Tp >1
107*43082ScaelAn error occurred.
108*43082Scael.Tp
109*43082Scael.Sh SEE ALSO
110*43082Scaeldiff 1 ,
111*43082Scaeldiff3 1
112*43082Scael.Sh STANDARDS
113*43082ScaelThe
114*43082Scael.Nm cmp
115*43082Scaelfunction is expected to be POSIX 1003.2 compatible.
116