diff
Quick Reference
Command Name:
diff
Category:
file management
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
- 1
File comparison
Compare two files line by line to identify differences
- 2
Code review
Review changes made to source code files
- 3
Configuration management
Track changes to configuration files between versions
- 4
Patch creation
Generate patch files that can be applied to update files
Syntax
diff [OPTION]... FILES
Options
Option | Description |
---|---|
-q, --brief |
Report only when files differ |
-s, --report-identical-files |
Report when two files are identical |
-c, -C NUM, --context[=NUM] |
Output NUM (default 3) lines of context |
-u, -U NUM, --unified[=NUM] |
Output NUM (default 3) lines of unified context |
-y, --side-by-side |
Output in two columns |
-i, --ignore-case |
Ignore case differences in file contents |
-w, --ignore-all-space |
Ignore all white space |
-B, --ignore-blank-lines |
Ignore changes where lines are all blank |
-r, --recursive |
Recursively compare any subdirectories found |
--color[=WHEN] |
Colorize the output; WHEN can be 'never', 'always', or 'auto' |
-a, --text |
Treat all files as text |
--help |
Display help information |
--version |
Display version information |
Examples
How to Use These Examples
The examples below show common ways to use the diff
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.