1*61942Sbostic.\" Copyright (c) 1987, 1990, 1993 2*61942Sbostic.\" The Regents of the University of California. 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*61942Sbostic.\" @(#)cmp.1 8.1 (Berkeley) 06/06/93 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 1950802Scael.Op Fl l | Fl s 2043082Scael.Ar file1 file2 2150802Scael.Op Ar skip1 Op Ar skip2 2243082Scael.Sh DESCRIPTION 2350431SbosticThe cmp utility compares two files of any type and writes the results 2450431Sbosticto 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: 3350802Scael.Bl -tag -width flag 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 4250431SbosticThe optional arguments 4350431Sbostic.Ar skip1 4450431Sbosticand 4550431Sbostic.Ar skip2 4650431Sbosticare the byte offsets from the beginning of 4743082Scael.Ar file1 4850431Sbosticand 4950431Sbostic.Ar file2 , 5050431Sbosticrespectively, where the comparison will begin. 5150431SbosticThe offset is decimal by default, but may be expressed as an hexadecimal 5250431Sbosticor 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 6650431Sbosticoption has not been specified, 6750431Sbostic.Nm cmp 6850431Sbosticwrites to standard output that EOF was reached in the shorter 6950431Sbosticfile (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 7950802Scaelutility is expected to be 8050802Scael.St -p1003.2 8150802Scaelcompatible. 82