Print this page
13507 some man pages need update following 13405
6308 some man pages are obsolete after moving to ksh builtins
   1 CMP(1)                           User Commands                          CMP(1)
   2 
   3 
   4 
   5 NAME
   6        cmp - compare two files
   7 
   8 SYNOPSIS
   9        cmp [-l | -s] file1 file2 [skip1] [skip2]
  10 
  11 
  12 DESCRIPTION
  13        The cmp utility compares two files. cmp writes no output if the files
  14        are the same. Under default options, if they differ, it writes to
  15        standard output the byte and line numbers at which the first difference
  16        occurred. Bytes and lines are numbered beginning with 1. If one file is
  17        an initial subsequence of the other, that fact is noted. skip1 and
  18        skip2 are initial byte offsets into file1 and file2 respectively, and
  19        can be either octal or decimal. A leading 0 denotes octal.
  20 



  21 OPTIONS
  22        The following options are supported:
  23 
  24        -l
  25              Write the byte number (decimal) and the differing bytes (octal)
  26              for each difference.
  27 


  28 
  29        -s
  30              Write nothing for differing files. Return exit status only.
  31 


  32 
  33 OPERANDS
  34        The following operands are supported:







  35 
  36        file1
  37                 A path name of the first file to be compared. If file1 is -,
  38                 the standard input is used.

  39 




  40 
  41        file2
  42                 A path name of the second file to be compared. If file2 is -,
  43                 the standard input is used.
  44 


  45 



  46 
  47        If both file1 and file2 refer to standard input or refer to the same
  48        FIFO special, block special or character special file, an error
  49        results.
  50 
  51 USAGE
  52        See largefile(5) for the description of the behavior of cmp when
  53        encountering files greater than or equal to 2 Gbyte (2^31 bytes).
  54 
  55 EXAMPLES
  56        Example 1 Comparing Files Byte for Byte
  57 


  58 
  59        The following example does a byte for byte comparison of file1 and
  60        file2:


  61 


  62 
  63          example% cmp file1 file2 0 1024

  64 


  65 

  66 

  67 
  68        It skips the first 1024 bytes in file2 before starting the comparison.
  69 





  70 


  71 ENVIRONMENT VARIABLES
  72        See environ(5) for descriptions of the following environment variables
  73        that affect the execution of cmp: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
  74        and NLSPATH.
  75 
  76 EXIT STATUS
  77        The following error values are returned:

  78 
  79        0
  80              The files are identical.
  81 
  82 
  83        1
  84              The files are different. This includes the case where one file is
  85              identical to the first part of the other.
  86 
  87 
  88        >1
  89              An error occurred.
  90 
  91 
  92 ATTRIBUTES
  93        See attributes(5) for descriptions of the following attributes:
  94 
  95 
  96 
  97 
  98        +--------------------+-----------------+
  99        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 100        +--------------------+-----------------+
 101        |CSI                 | Enabled         |
 102        +--------------------+-----------------+
 103        |Interface Stability | Standard        |
 104        +--------------------+-----------------+
 105 
 106 SEE ALSO
 107        comm(1), diff(1), attributes(5), environ(5), largefile(5), standards(5)
 108 
 109 
 110 
 111                                  July 19, 2006                          CMP(1)
   1 CMP(1)                           User Commands                          CMP(1)
   2 


   3 NAME
   4      cmp - compare two files
   5 
   6 SYNOPSIS
   7      cmp [-bcdilns] file1 file2 [skip1 [skip2]]
   8 

   9 DESCRIPTION
  10      The cmp utility compares two files.  cmp writes no output if the files
  11      are the same.  Under default options, if they differ, it writes to
  12      standard output the byte and line numbers at which the first difference
  13      occurred.  Bytes and lines are numbered beginning with 1.  skip1 and
  14      skip2 are initial byte offsets into file1 and file2 respectively, and are
  15      specified in bytes or can be given with a suffix of k for kilobytes or m
  16      for megabytes.
  17 
  18      If either file1 or file2 is a dash (-), cmp uses standard input starting
  19      at the current location.
  20 
  21 OPTIONS
  22      The following options are supported:
  23 
  24      -b, --print-bytes
  25                    Print differing bytes as 3-digit octal values.

  26 
  27      -c, --print-chars
  28                    Print differing bytes as follows:
  29 
  30                    o       non-space printable characters as themselves;

  31 
  32                    o       space and control characters as ^ followed by a
  33                            letter of the alphabet;
  34 
  35                    o       characters with the high bit set as the lower 7-bit
  36                            character prefixed by M^ for 7-bit space and non-
  37                            printable characters, and M- for all other
  38                            characters.  If the 7-bit character encoding is not
  39                            ASCII then the characters are converted to ASCII to
  40                            determine whether the high bit is set and, if set,
  41                            it is cleared and converted back to the native
  42                            encoding.  Multibyte characters in the current
  43                            locale are treated as printable characters.
  44 
  45      -d differences, --differences=differences
  46                    Print at most differences differences using -l (--verbose)
  47                    output format.  If differences is 0 then this is equivalent
  48                    to passing the -s or --silent option.
  49 
  50      -i skip1[:skip2, --skip=skip1[:skip2, --ignore-initial=skip1[:skip2]]]
  51                    Skip the first skip1 bytes in file1 and the first skip2
  52                    bytes in file2.  If skip2 is omitted then skip1 is used for
  53                    that value.  The default value is 0:0.
  54 
  55      -l, --verbose
  56                    Write the byte number (decimal) and the differing bytes
  57                    (octal) for each difference.
  58 
  59      -n count, --count=count, --bytes=count
  60                    Compare at most count bytes.
  61 
  62      -s, --silent -, --quiet
  63                    Write nothing for differing files.  Return exit status
  64                    only.
  65 
  66 OPERANDS
  67      The following operands are supported:

  68 
  69      file1         A path name of the first file to be compared.  If file1 is
  70                    -, the standard input is used.

  71 
  72      file2         A path name of the second file to be compared.  If file2 is
  73                    -, the standard input is used.
  74 
  75      skip1         The number of initial bytes from file1 to skip before
  76                    beginning the comparison.
  77 
  78      skip2         The number of initial bytes from file2 to skip before
  79                    beginning the comparison.  If skip1 is specified but skip2
  80                    is not, then the value of skip1 is also implicitly used for
  81                    skip2.
  82 
  83      If both file1 and file2 refer to standard input or refer to the same
  84      FIFO, block or character special file, an error results.
  85 
  86      skip values are specified in bytes, or can be suffixed with k (for
  87      kilobytes) or m (for megabytes.)
  88 
  89 EXIT STATUS
  90      The following exit values are returned:
  91 
  92      0       The files or portions compared are identical.
  93 
  94      1       The files or portions compared are different.
  95 
  96      >1           An error ocurred.
  97 
  98 EXAMPLES
  99      Example 1 Comparing Files Byte for Byte
 100              The following example does a byte for byte comparison of file1
 101              and file2, skipping the first 1024 bytes in file2 before starting
 102              the comparison.
 103 
 104              $ cmp file1 file2 0 1024
 105 
 106 ENVIRONMENT VARIABLES
 107      See environ(5) for descriptions of the following environment variables
 108      that affect the execution of cmp: LANG, LC_ALL, LC_TYPE, LC_MESSAGES,
 109      LC_NUMERIC, and NLSPATH.
 110 
 111 INTERFACE STABILITY
 112      The command line interface of cmp is Committed.  The output of cmp is
 113      Standard.
 114 



























 115 SEE ALSO
 116      comm(1), diff(1), attributes(5), environ(5), largefile(5), standards(5)
 117 
 118 illumos                        February 9, 2021                        illumos