Text and processing
The cmp command
Compares two files byte by byte and says exactly at which byte and line they differ.
Syntax
cmp archivo1 archivo2Most useful options
-sSilent: only returns the exit code-lShows every differenceCopy-ready examples
$ printf 'a\n' > x.txt && cmp x.txt x.txtCompare (no output if equal)You can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- cmp prints nothing if the files are identical; that means they are fine.
FAQ
cmp or diff?
cmp is to know whether they are equal and where; diff to see readable differences.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course