143082Scael.\" Copyright (c) 1987, 1990 The Regents of the University of California. 243082Scael.\" All rights reserved. 319387Smckusick.\" 450183Sbostic.\" This code is derived from software contributed to Berkeley by 550183Sbostic.\" the Institute of Electrical and Electronics Engineers, Inc. 650183Sbostic.\" 743082Scael.\" %sccs.include.redist.man% 832644Sbostic.\" 9*50431Sbostic.\" @(#)cmp.1 6.8 (Berkeley) 07/18/91 1043082Scael.\" 1143082Scael.Dd 1243082Scael.Dt CMP 1 1347399Scael.Os 1443082Scael.Sh NAME 1543082Scael.Nm cmp 1643082Scael.Nd compare two files 1743082Scael.Sh SYNOPSIS 1843082Scael.Nm cmp 1944952Scael.Op Fl l Li \&| Fl s 2043082Scael.Ar file1 file2 21*50431Sbostic.Op Ar skip1 Ar skip2 2243082Scael.Sh DESCRIPTION 23*50431SbosticThe cmp utility compares two files of any type and writes the results 24*50431Sbosticto the standard output. 2550070SbosticBy default, 2644952Scael.Nm 2750070Sbosticis silent if the files are the same; if they differ, the byte 2850070Sbosticand line number at which the first difference occurred is reported. 2943082Scael.Pp 3050070SbosticBytes and lines are numbered beginning with one. 3150070Sbostic.Pp 3243082ScaelThe following options are available: 3347399Scael.Bl -tag -width Ds 3447399Scael.It Fl l 3543082ScaelPrint the byte number (decimal) and the differing 3650070Sbosticbyte values (octal) for each difference. 3747399Scael.It Fl s 3843082ScaelPrint nothing for differing files; return exit 3943082Scaelstatus only. 4047399Scael.El 4143082Scael.Pp 42*50431SbosticThe optional arguments 43*50431Sbostic.Ar skip1 44*50431Sbosticand 45*50431Sbostic.Ar skip2 46*50431Sbosticare the byte offsets from the beginning of 4743082Scael.Ar file1 48*50431Sbosticand 49*50431Sbostic.Ar file2 , 50*50431Sbosticrespectively, where the comparison will begin. 51*50431SbosticThe offset is decimal by default, but may be expressed as an hexadecimal 52*50431Sbosticor octal value by preceding it with a leading ``0x'' or ``0''. 5343082Scael.Pp 5443082ScaelThe 5543082Scael.Nm cmp 5643082Scaelutility exits with one of the following values: 5747399Scael.Bl -tag -width 4n 5847399Scael.It 0 5943082ScaelThe files are identical. 6047399Scael.It 1 6143082ScaelThe files are different; this includes the case 6243082Scaelwhere one file is identical to the first part of 6343082Scaelthe other. 6444952ScaelIn the latter case, if the 6544952Scael.Fl s 66*50431Sbosticoption has not been specified, 67*50431Sbostic.Nm cmp 68*50431Sbosticwrites to standard output that EOF was reached in the shorter 69*50431Sbosticfile (before any differences were found). 7047399Scael.It >1 7143082ScaelAn error occurred. 7247399Scael.El 7343082Scael.Sh SEE ALSO 7444952Scael.Xr diff 1 , 7544952Scael.Xr diff3 1 7643082Scael.Sh STANDARDS 7743082ScaelThe 7843082Scael.Nm cmp 7943082Scaelfunction is expected to be POSIX 1003.2 compatible. 80