cmp in Mac OS X

By: Strauss K  

Compare two files.
The cmp utility compares two files of any type and writes the results to the standard output. By default, 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.

Syntax
      cmp [option..] file1 [file2 [skip1 [skip2]]]

Options
   -b  --print-bytes
              Print differing bytes.

   -i SKIP  --ignore-initial=SKIP
              Skip the first SKIP bytes of input.

   -i SKIP1:SKIP2  --ignore-initial=SKIP1:SKIP2
              Skip the first SKIP1 bytes of FILE1 and the first SKIP2 bytes of
              FILE2.

   -l  --verbose
              Output byte numbers and values of all differing bytes.

   -n LIMIT  --bytes=LIMIT
              Compare at most LIMIT bytes.

   -s  --quiet  --silent
              Output nothing; yield exit status only.

   -v  --version
              Output version info.

   --help Output help.

Notes
skip1 and skip2 are the number of bytes to skip in each file. SKIP values may be followed by the following multiplicative suffixes: kB 1000, K 1024, MB 1,000,000, M 1,048,576, GB 1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y.
The offset is decimal by default, but may be expressed as a hex or octal value by preceding it with a leading `0x' or `0'.

info diff will return full examples for both diff and cmp

If a File is - or missing, read from standard input.

cmp exits with one of the following values:

0 The files are identical.
1 The files are different; this includes the case where one file is identical to the first part of the other. In the latter case, if the -s option has not been specified, cmp writes to standard output that EOF was reached in the shorter file (before any differences were found).
>1 An error occurred.




Archived Comments

1. Brettkip
View Tutorial          By: Brettkip at 2017-07-27 12:36:30

2. I have a mac book dual booting with snow leopard (OSX 10.6.2) and Windows XP.
I was cleaning

View Tutorial          By: david at 2015-06-27 15:33:07


Most Viewed Articles (in macos )

Latest Articles (in macos)

Comment on this tutorial