Hamilton LaboratoriesHamilton C shell 2012User guideExternal utilities

cmp

Oregon Coast

cmp
Previous | Next

        Binary Compare Two Files or Directories

Usage:  cmp [-lsdxoph-] [-r<radix>] file1 file2

   cmp compares files and directories, byte by byte.  If they
   are identical, cmp writes no output and exits with a return
   code of 0.  If they differ, cmp will, by default, report the
   location of the first difference and exit with a return code
   of 1.

   If one operand is a directory and the other is a file, cmp
   will look for and compare against a file of that same name
   in the directory.

   Comparing directories, cmp builds lists of all the files
   they contain, searching all the way down through the tree.
   The lists are sorted, then compared.  If the same filename
   exists in each directory tree, they are compared.

   The first difference will be reported by line number, always
   in decimal, and offset from the start of the file, counting
   from zero, in the radix specified with the -d, -x, -o or -r
   option, or by the RADIX environment variable, if set, or in
   the default radix 16 (hex).

Options:

   -l           List all the differences, showing, for each, the
                offset from the beginning of the file and the
                values of the differing characters.  Offsets and
                and character values will be shown in the radix
                chosen by the user.
   -s           Write nothing for differing files; just set
                the return code.
   -p           POSIX-compatible reporting:  any message text
                will be presented exactly as specified by the
                POSIX 1003.2 standard, offsets within the files
                will be counted starting at 1, not 0, and the
                values of any differing bytes will be shown in
                octal.
   -d           Decimal radix.
   -x           Hex.
   -o           Octal.
   -r<radix>    User-specified radix.  If a radix < 8 is specified,
                only the character values will be shown in that
                radix; offsets will be shown in hex.
   -h           Help.  (This screen.)
   --           End of options.

Previous | Next