xref: /csrg-svn/usr.bin/cmp/cmp.1 (revision 47399)
143082Scael.\" Copyright (c) 1987, 1990 The Regents of the University of California.
243082Scael.\" All rights reserved.
319387Smckusick.\"
443082Scael.\" %sccs.include.redist.man%
532644Sbostic.\"
6*47399Scael.\"     @(#)cmp.1	6.5 (Berkeley) 03/14/91
743082Scael.\"
843082Scael.Dd
943082Scael.Dt CMP 1
10*47399Scael.Os
1143082Scael.Sh NAME
1243082Scael.Nm cmp
1343082Scael.Nd compare two files
1443082Scael.Sh SYNOPSIS
1543082Scael.Nm cmp
1644952Scael.Op Fl l Li \&| Fl s
1743082Scael.Ar file1 file2
1843082Scael.Sh DESCRIPTION
1944952ScaelThe cmp utility compares two files of any type and
2044952Scaelwrites the results to the standard output.
2143082ScaelUnder default options,
2244952Scael.Nm
2344952Scaelis silent
2444952Scaelif the files are the same; if they
2544952Scaeldiffer, the byte and line
2644952Scaelnumber at which the first difference occurred is reported.
2743082ScaelBytes and
2843082Scaellines are numbered beginning with one.
2943082Scael.Pp
3043082ScaelThe following options are available:
31*47399Scael.Bl -tag -width Ds
32*47399Scael.It Fl l
3343082ScaelPrint the byte number (decimal) and the differing
3444952Scaelbyte values (octal) for each difference, respectively.
35*47399Scael.It Fl s
3643082ScaelPrint nothing for differing files; return exit
3743082Scaelstatus only.
38*47399Scael.El
3943082Scael.Pp
4043082ScaelThe following operands are available:
41*47399Scael.Bl -tag -width file1
42*47399Scael.It Ar file1
4343082ScaelA pathname of the first file to be compared.
4443082ScaelIf
4543082Scael.Ar file1
4643082Scaelis
4744952Scael.Sq Fl ,
4843082Scaelthe standard input is used.
49*47399Scael.It Ar file2
5043082ScaelA pathname of the second file to be compared.
51*47399Scael.El
5243082Scael.Pp
5343082ScaelThe
5443082Scael.Nm cmp
5543082Scaelutility exits with one of the following values:
56*47399Scael.Bl -tag -width 4n
57*47399Scael.It 0
5843082ScaelThe files are identical.
59*47399Scael.It 1
6043082ScaelThe files are different; this includes the case
6143082Scaelwhere one file is identical to the first part of
6243082Scaelthe other.
6344952ScaelIn the latter case, if the
6444952Scael.Fl s
6544952Scaeloption has
6643082Scaelnot been specified, cmp writes to standard error
6743082Scaelthat EOF was reached in the shorter file (before
6843082Scaelany differences were found).
69*47399Scael.It >1
7043082ScaelAn error occurred.
71*47399Scael.El
7243082Scael.Sh SEE ALSO
7344952Scael.Xr diff 1 ,
7444952Scael.Xr diff3 1
7543082Scael.Sh STANDARDS
7643082ScaelThe
7743082Scael.Nm cmp
7843082Scaelfunction is expected to be POSIX 1003.2 compatible.
7944952ScaelThis manual page is derived from the POSIX 1003.2 manual page.
80