diff command
Compare files line by line.
- Text processing
- Package diffutils
- 7 options · 6 examples
On this page
Syntax
diff [options] file1 file2Provided by the diffutils package. Run man diff for the full manual.
Common options
| Option | What it does |
|---|---|
-u | Unified format (what git shows) |
-y | Side by side |
-r | Compare directories recursively |
-q | Only say whether files differ |
-i | Ignore case |
-w | Ignore all whitespace |
--color | Colour the output |
Examples
Compare two files
diff old.conf new.confUnified diff
diff -u old.conf new.confSide by side
diff -y --width=160 a.txt b.txtCompare directories
diff -rq dir1/ dir2/Ignore whitespace
diff -w a.py b.pyCreate a patch
diff -u original.c fixed.c > fix.patch
No example matches. Check the options table or search the guides.
diff guides
- How To Compare Two Files in Linux Linux Commands · Updated Apr 2025
