# man > cmp(1ssl)

---
type: CommandReference
command: cmp
mode: man
section: 1
source: man-pages
---

## Quick Reference

- `cmp file1 file2` — compare two files byte by byte, output first difference
- `cmp -b file1 file2` — output char, line number, bytes, and values of first difference
- `cmp -l file1 file2` — output byte numbers and values of every difference
- `cmp -s file1 file2` — suppress output, only return exit status (0=same, 1=different, 2=error)

## Name

cmp - compare two files byte by byte

## Synopsis

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

## Options

- `-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 for every difference
- `-n, --bytes=LIMIT` — compare at most LIMIT bytes
- `-s, --quiet, --silent` — suppress all normal output
- `--help` — display help and exit
- `-v, --version` — output version information and exit

SKIP values accept 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 similarly for `T`, `P`, `E`, `Z`, `Y`.

If a FILE is `-` or missing, read standard input.

## Examples

shell
cmp file1 file2
Output char and line number of the first difference.

shell
cmp -b file1 file2
Output info of the first difference: char, line number, bytes, and values.

shell
cmp -l file1 file2
Output the byte numbers and values of every difference.

shell
cmp -s file1 file2
Compare files but output nothing, yield only the exit status.

## Exit Codes

- `0` — inputs are identical
- `1` — inputs differ
- `2` — trouble (e.g., cannot read file)

## See Also

[diff(1)](https://www.chedong.com/phpMan.php/man/diff/1/markdown), [diff3(1)](https://www.chedong.com/phpMan.php/man/diff3/1/markdown), [sdiff(1)](https://www.chedong.com/phpMan.php/man/sdiff/1/markdown)