Skip to main content

Compare two files byte by byte.

# To compare two files:
cmp file1 file2

# To skip the same number of initial bytes (10) from both input files:
cmp -i 10 file1 file2

# To skip a different number of initial bytes from both input files:
cmp -i 5:2 file1 file2

# To put a limit on the number of bytes to compare (20):
cmp -n 10 file1 file2

# To silently compare two files:
cmp --silent file1 file2 || echo "files are different"