143082Scael.\" Copyright (c) 1987, 1990 The Regents of the University of California. 243082Scael.\" All rights reserved. 319387Smckusick.\" 443082Scael.\" %sccs.include.redist.man% 532644Sbostic.\" 6*44952Scael.\" @(#)cmp.1 6.4 (Berkeley) 07/24/90 743082Scael.\" 843082Scael.Dd 943082Scael.Dt CMP 1 1043082Scael.Os BSD 4.4 1143082Scael.Sh NAME 1243082Scael.Nm cmp 1343082Scael.Nd compare two files 1443082Scael.Sh SYNOPSIS 1543082Scael.Nm cmp 16*44952Scael.Op Fl l Li \&| Fl s 1743082Scael.Ar file1 file2 1843082Scael.Sh DESCRIPTION 19*44952ScaelThe cmp utility compares two files of any type and 20*44952Scaelwrites the results to the standard output. 2143082ScaelUnder default options, 22*44952Scael.Nm 23*44952Scaelis silent 24*44952Scaelif the files are the same; if they 25*44952Scaeldiffer, the byte and line 26*44952Scaelnumber at which the first difference occurred is reported. 2743082ScaelBytes and 2843082Scaellines are numbered beginning with one. 2943082Scael.Pp 3043082ScaelThe following options are available: 31*44952Scael.Tw Ds 3243082Scael.Tp Fl l 3343082ScaelPrint the byte number (decimal) and the differing 34*44952Scaelbyte values (octal) for each difference, respectively. 3543082Scael.Tp Fl s 3643082ScaelPrint nothing for differing files; return exit 3743082Scaelstatus only. 3843082Scael.Tp 3943082Scael.Pp 4043082ScaelThe following operands are available: 4143082Scael.Tw file1 4243082Scael.Tp Ar file1 4343082ScaelA pathname of the first file to be compared. 4443082ScaelIf 4543082Scael.Ar file1 4643082Scaelis 47*44952Scael.Sq Fl , 4843082Scaelthe standard input is used. 4943082Scael.Tp Ar file2 5043082ScaelA pathname of the second file to be compared. 5143082Scael.Tp 5243082Scael.Pp 5343082ScaelThe 5443082Scael.Nm cmp 5543082Scaelutility exits with one of the following values: 56*44952Scael.Tw Ds 5743082Scael.Tp 0 5843082ScaelThe files are identical. 5943082Scael.Tp 1 6043082ScaelThe files are different; this includes the case 6143082Scaelwhere one file is identical to the first part of 6243082Scaelthe other. 63*44952ScaelIn the latter case, if the 64*44952Scael.Fl s 65*44952Scaeloption has 6643082Scaelnot been specified, cmp writes to standard error 6743082Scaelthat EOF was reached in the shorter file (before 6843082Scaelany differences were found). 6943082Scael.Tp >1 7043082ScaelAn error occurred. 7143082Scael.Tp 7243082Scael.Sh SEE ALSO 73*44952Scael.Xr diff 1 , 74*44952Scael.Xr diff3 1 7543082Scael.Sh STANDARDS 7643082ScaelThe 7743082Scael.Nm cmp 7843082Scaelfunction is expected to be POSIX 1003.2 compatible. 79*44952ScaelThis manual page is derived from the POSIX 1003.2 manual page. 80