Section: diff, cmp, and patch-Oriented Comparison

Compare files byte by byte

bash
bash
cmp file1.bin file2.bin
Explanation

`cmp` is simpler than diff when you only need to know whether files differ and where the first difference occurs.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing diff, cmp, and patch-Oriented Comparison
Show unified diff
Compare two text files with context.
OpenIn sheetbashsame section
Compare directories recursively
Find differences across two directory trees.
OpenIn sheetbashsame section
Show side-by-side diff
Compare files in two visual columns.
OpenIn sheetbashsame section
Pass stdin items as arguments
Convert lines into command arguments.
Split a file by line count
Create chunks of 1000 lines each.
Show most frequent error messages
Count and rank repeated lines in a log.