cmp(1)

cmp1

Compare two files byte by byte

Usage

cmp [OPTION] ... FILE1 [FILE2 [SKIP1 [SKIP2]]]

Overview

Compare two files byte by byte.

The optional SKIP1 and SKIP2 specify the number of bytes to skip at the beginning of each file (zero by default).

Mandatory arguments to long options are mandatory for short options too.

-b, --print-bytes

print differing bytes

-i, --ignore-initial=SKIP

skip first SKIP bytes of both inputs

-i, --ignore-initial=SKIP1:SKIP2

skip first SKIP1 bytes of FILE1 and first SKIP2 bytes of FILE2

-l, --verbose

output byte numbers and differing byte values

-n, --bytes=LIMIT

compare at most LIMIT bytes

-s, --quiet, --silent

suppress all normal output

--help

display this help and exit

-v, --version

output version information and exit

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.

If a FILE is '-' or missing, read standard input. Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.

Releases

19 releases since Debian 1.1 (Buzz); the text changed 10 times.

  1. 1.1–2.1
  2. 2.2–3.0
  3. 3.1–5.0
  4. 6.0
  5. 7
  6. 8
  7. 9
  8. 10–11
  9. 12
  10. 13
  11. Arch

--bytes since Debian 7 (Wheezy); --help since Debian 3.1 (Sarge); --ignore-initial since Debian 7 (Wheezy); --print-bytes since Debian 3.1 (Sarge); --quiet since Debian 2.2 (Potato); --silent since Debian 2.2 (Potato); --verbose since Debian 2.2 (Potato); --version since Debian 2.2 (Potato); -b since Debian 3.1 (Sarge); -i since Debian 7 (Wheezy); -n since Debian 7 (Wheezy); -v since Debian 2.2 (Potato).

--print-chars until Debian 3.0 (Woody); -c until Debian 3.0 (Woody).

Author

Written by Torbjorn Granlund and David MacKenzie.

Reporting bugs

Report bugs to: [email protected]
GNU diffutils home page: <https://www.gnu.org/software/diffutils/>
General help using GNU software: <https://www.gnu.org/gethelp/>

From diffutils 3.12-2 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.