Print this page
13507 some man pages need update following 13405
6308 some man pages are obsolete after moving to ksh builtins
@@ -1,6 +1,5 @@
-.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
@@ -41,163 +40,218 @@
.\"
.\"
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
+.\" Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
.\"
-.TH CMP 1 "Jul 19, 2006"
-.SH NAME
-cmp \- compare two files
-.SH SYNOPSIS
-.LP
-.nf
-\fBcmp\fR [\fB-l\fR | \fB-s\fR] \fIfile1\fR \fIfile2\fR [\fIskip1\fR] [\fIskip2\fR]
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBcmp\fR utility compares two files. \fBcmp\fR writes no output if the
-files are the same. Under default options, if they differ, it writes to
-standard output the byte and line numbers at which the first difference
-occurred. Bytes and lines are numbered beginning with 1. If one file is an
-initial subsequence of the other, that fact is noted. \fIskip1\fR and
-\fIskip2\fR are initial byte offsets into \fIfile1\fR and \fIfile2\fR
-respectively, and can be either octal or decimal. A leading 0 denotes octal.
-.SH OPTIONS
-.sp
-.LP
+.Dd Feb 9, 2021
+.Dt CMP 1
+.Os
+.Sh NAME
+.Nm cmp
+.Nd compare two files
+.Sh SYNOPSIS
+.Nm
+.Op Fl bcdilns
+.Ar file1 file2
+.Op Ar skip1 Op Ar skip2
+.Sh DESCRIPTION
+The
+.Nm
+utility compares two files.
+.Nm
+writes no output if the files are the same.
+Under default options, if they differ, it writes to standard output the byte
+and line numbers at which the first difference occurred.
+Bytes and lines are numbered beginning with 1.
+.Ar skip1
+and
+.Ar skip2
+are initial byte offsets into
+.Ar file1
+and
+.Ar file2
+respectively, and are specified in bytes or can be given with a suffix of
+.Cm k
+for kilobytes or
+.Cm m
+for megabytes.
+.Lp
+If either
+.Ar file1
+or
+.Ar file2
+is a dash
+.Pq Ar \(mi ,
+.Nm
+uses standard input starting at the current location.
+.Sh OPTIONS
The following options are supported:
-.sp
-.ne 2
-.na
-\fB\fB-l\fR\fR
-.ad
-.RS 6n
+.Bl -tag -width Ar
+.It Fl b Ns \&, Fl \-print-bytes
+Print differing bytes as 3-digit octal values.
+.It Fl c Ns \&, Fl \-print-chars
+Print differing bytes as follows:
+.Bl -bullet -width Ds
+.It
+non-space printable characters as themselves;
+.It
+space and control characters as
+.Em ^
+followed by a letter of the alphabet;
+.It
+characters with the high bit set as the lower 7-bit character prefixed by
+.Em M^
+for 7-bit space and non-printable characters, and
+.Em M-
+for all other characters.
+If the 7-bit character encoding is not ASCII then the characters are converted
+to ASCII to determine whether the high bit is set and, if set, it is cleared
+and converted back to the native encoding.
+Multibyte characters in the current locale are treated as printable characters.
+.El
+.It Fl d Ar differences Ns \&, Fl \-differences Ns = Ns Ar differences
+Print at most
+.Ar differences
+differences using
+.Fl l
+.Pq Fl -verbose
+output format.
+If
+.Ar differences
+is
+.Cm 0
+then this is equivalent to passing the
+.Fl s
+or
+.Fl \-silent
+option.
+.It Fl i Ar skip1 Ns Op : Ns Ar skip2 Ns \&, Fl -skip Ns = Ns Ar skip1 Ns Op : Ns Ar skip2 Ns \&, Fl -ignore-initial Ns = Ns Ar skip1 Ns Op : Ns Ar skip2
+Skip the first
+.Ar skip1
+bytes in
+.Ar file1
+and the first
+.Ar skip2
+bytes in
+.Ar file2 .
+If
+.Ar skip2
+is omitted then
+.Ar skip1
+is used for that value.
+The default value is
+.Ar 0:0 .
+.It Fl l Ns \&, Fl \-verbose
Write the byte number (decimal) and the differing bytes (octal) for each
difference.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-s\fR\fR
-.ad
-.RS 6n
-Write nothing for differing files. Return exit status only.
-.RE
-
-.SH OPERANDS
-.sp
-.LP
+.It Fl n Ar count Ns \&, Fl \-count Ns = Ns Ar count Ns \&, Fl \-bytes Ns = Ns Ar count
+Compare at most
+.Ar count
+bytes.
+.It Fl s Ns \&, Fl \-silent \&, Fl \-quiet
+Write nothing for differing files.
+Return exit status only.
+.El
+.Sh OPERANDS
The following operands are supported:
-.sp
-.ne 2
-.na
-\fB\fIfile1\fR\fR
-.ad
-.RS 9n
-A path name of the first file to be compared. If \fIfile1\fR is \fB\(mi\fR, the
-standard input is used.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fIfile2\fR\fR
-.ad
-.RS 9n
-A path name of the second file to be compared. If \fIfile2\fR is \fB\(mi\fR,
+.Bl -tag -width Ar
+.It Ar file1
+A path name of the first file to be compared.
+If
+.Ar file1
+is
+.Ar \(mi ,
the standard input is used.
-.RE
-
-.sp
-.LP
-If both \fIfile1\fR and \fIfile2\fR refer to standard input or refer to the
-same \fBFIFO\fR special, block special or character special file, an error
-results.
-.SH USAGE
-.sp
-.LP
-See \fBlargefile\fR(5) for the description of the behavior of \fBcmp\fR when
-encountering files greater than or equal to 2 Gbyte (2^31 bytes).
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRComparing Files Byte for Byte
-.sp
-.LP
-The following example does a byte for byte comparison of \fIfile1\fR and
-\fIfile2\fR:
-
-.sp
-.in +2
-.nf
-example% \fBcmp file1 file2 0 1024\fR
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-It skips the first 1024 bytes in \fIfile2\fR before starting the comparison.
-
-.SH ENVIRONMENT VARIABLES
-.sp
-.LP
-See \fBenviron\fR(5) for descriptions of the following environment variables
-that affect the execution of \fBcmp\fR: \fBLANG\fR, \fBLC_ALL\fR,
-\fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
-.SH EXIT STATUS
-.sp
-.LP
-The following error values are returned:
-.sp
-.ne 2
-.na
-\fB\fB0\fR\fR
-.ad
-.RS 6n
-The files are identical.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB1\fR\fR
-.ad
-.RS 6n
-The files are different. This includes the case where one file is identical to
-the first part of the other.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB>1\fR\fR
-.ad
-.RS 6n
-An error occurred.
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-CSI Enabled
-_
-Interface Stability Standard
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBcomm\fR(1), \fBdiff\fR(1), \fBattributes\fR(5), \fBenviron\fR(5),
-\fBlargefile\fR(5), \fBstandards\fR(5)
+.It Ar file2
+A path name of the second file to be compared.
+If
+.Ar file2
+is
+.Ar \(mi ,
+the standard input is used.
+.It Ar skip1
+The number of initial bytes from
+.Ar file1
+to skip before beginning the comparison.
+.It Ar skip2
+The number of initial bytes from
+.Ar file2
+to skip before beginning the comparison.
+If
+.Ar skip1
+is specified but
+.Ar skip2
+is not, then the value of
+.Ar skip1
+is also implicitly used for
+.Ar skip2 .
+.El
+.Pp
+If both
+.Ar file1
+and
+.Ar file2
+refer to standard input or refer to the same FIFO, block or character special
+file, an error results.
+.Pp
+.Ar skip
+values are specified in bytes, or can be suffixed with
+.Cm k
+.Pq for kilobytes
+or
+.Cm m
+.Pq for megabytes.
+.Sh EXIT STATUS
+The following exit values are returned:
+.Bl -tag -width Ds
+.It Sy 0
+The files or portions compared are identical.
+.It Sy 1
+The files or portions compared are different.
+.It Sy >1
+An error ocurred.
+.El
+.Sh EXAMPLES
+.Bl -tag -width Ds
+.It Sy Example 1 No Comparing Files Byte for Byte
+The following example does a byte for byte comparison of
+.Ar file1
+and
+.Ar file2 ,
+skipping the first 1024 bytes in
+.Ar file2
+before starting the comparison.
+.Bd -literal
+$ cmp file1 file2 0 1024
+.Ed
+.El
+.Sh ENVIRONMENT VARIABLES
+See
+.Xr environ 5
+for descriptions of the following environment variables
+that affect the execution of
+.Nm :
+.Ev LANG ,
+.Ev LC_ALL ,
+.Ev LC_TYPE ,
+.Ev LC_MESSAGES ,
+.Ev LC_NUMERIC ,
+and
+.Ev NLSPATH .
+.Sh INTERFACE STABILITY
+The command line interface of
+.Nm
+is
+.Sy Committed .
+The output of
+.Nm
+is
+.Sy Standard .
+.Sh SEE ALSO
+.Xr comm 1 ,
+.Xr diff 1 ,
+.Xr attributes 5 ,
+.Xr environ 5 ,
+.Xr largefile 5 ,
+.Xr standards 5