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