File: cmp.1

package info (click to toggle)
diff 2.7-29
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,300 kB
  • ctags: 984
  • sloc: ansic: 11,043; sh: 216; makefile: 204
file content (147 lines) | stat: -rw-r--r-- 3,348 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
.\" cmp(1) by Peter Samuelson <psamuels@sampo.creighton.edu> 23 September 1998
.\"
.\" Originally derived from the Debian Linux 2.0 distribution, who got
.\" it from FreeBSD, but I rewrote and reformatted this so extensively
.\" (using the manual page from GNU grep as a sort of template since I
.\" don't know roff very well) that I don't feel the need to retain the
.\" UCB copyright notice.
.\"
.\" This documents cmp from GNU diffutils version 2.7, with the byte
.\" ranges extension by Peter Samuelson.  It is in the public domain.
..
.TH CMP 1 "1998 September 23" "GNU Project"
..
.SH NAME
cmp (GNU diffutils) \- compare two files or byte ranges
..
.SH SYNOPSIS
.B cmp
[-clsv] [-i NUM] [--help] [--print-chars] [--ignore-initial=NUM]
[--verbose] [--quiet] [--silent] [--version] -I FILE1 [FILE2 [RANGE1
[RANGE2]]]
..
.SH DESCRIPTION
.PP
The
.B cmp
utility compares two files of any type and writes the results to the
standard output.  By default,
.B cmp
is silent if the files are the same; if they differ, the byte and line
number at which the first difference occurred is reported.
.PP
In the output, bytes and lines are numbered beginning with one;
however, range inputs are zero-based; see below for details.  A
filename of
.I -
represents standard input.
.PP
The following options are available:
.PD 0
.TP
.B "-c, --print-chars"
Output the differing bytes as characters, rather than as octal
numbers.  Non-printable characters will be shown in \ooo form.
.TP
.B "-i NUM, --ignore-initial=NUM"
Ignore
.I NUM
initial characters from each file.  This is a synonym for specifying
.I "NUM NUM"
as the two
.I RANGE
arguments.
.TP
.B "-l, --verbose"
Print the byte number (decimal) and the differing byte values (octal)
for each difference.
.TP
.B "-s, --quiet, --silent"
Print nothing for differing files; return exit status only.
.TP
.B "-v, --version"
Print the
.B diffutils
version number.
.PD
..
.SH "BYTE RANGES"
.PP
The two optional arguments
.I RANGE1
and
.I RANGE2
represent byte ranges to compare within the files.  Each range can be
expressed in several ways:
.PD 0
.TP
.B M+N
Skip
.I M
bytes at the beginning of the input, then compare a maximum of
.I N
bytes.
.TP
.B "M-N, M,N"
Skip
.I M
bytes at the beginning of the input, and read between bytes
.I M
and
.IR N ,
which are both zero-based.
.PD
.PP
In either case, both
.I M
and
.I N
are optional and default to beginning and end of file, respectively.
In addition, they can be expressed in decimal, octal
.RI ( 0NNN )
or hexadecimal
.RI ( 0xNNN )
form.
..
.SH NOTES
The zero-based range numbers may seem inconsistent with
.B cmp
output, which is one-based; this is for compatibility with some
versions of
.B cmp
which allow "skip
.I N
bytes" parameters after the filenames; in this context, the
.I N
is zero-based.
..
.SH DIAGNOSTICS
.PP
The
.B cmp
utility exits with one of the following values:
.PD 0
.TP
.B 0
The files or byte ranges are identical.
.TP
.B 1
The files or byte ranges are different; this includes the case where
one file or range is identical to the first part of the other.  In the
latter case, if
.B \-s
has not been specified,
.B cmp
writes to standard output that EOF was reached in the shorter file.
.TP
.B >1
An error occurred.
.PD
.SH SEE ALSO
.BR diff (1),
.BR diff3 (1)
.SH STANDARDS
The
.B cmp
utility is expected to be
.IR "POSIX 1003.2" -compliant.