Text and processing
The diff command
Compares two files line by line and shows the differences. It is the basis of patches and version control.
Syntax
diff archivo1 archivo2Most useful options
-uUnified format, easier to read-iIgnores caseCopy-ready examples
$ printf 'a\n' > uno.txt && diff uno.txt uno.txtCompare (no output if equal)You can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- diff prints nothing when the files are identical; silence is good news.
- It returns a non-zero exit code if there are differences.
FAQ
How does it differ from cmp?
diff compares line by line; cmp compares byte by byte.
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