diff
Compare files line by line
Overview
Compares two files line by line and outputs the differences. It can also compare directories.
Syntax
diff [OPTION]... FILESCommon Options
-i, --ignore-caseIgnore case distinctions in file contents.
-w, --ignore-all-spaceIgnore all white space.
-b, --ignore-space-changeIgnore changes in the amount of white space.
-B, --ignore-blank-linesIgnore changes whose lines are all blank.
-u, -U NUM, --unified[=NUM]Output NUM (default 3) lines of unified context. This is a common format for patches.
-c, -C NUM, --context[=NUM]Output NUM (default 3) lines of copied context.
-r, --recursiveRecursively compare any subdirectories found.
-q, --briefReport only when files differ.
--suppress-common-linesDo not display common lines (useful with side-by-side).
-y, --side-by-sideOutput in two columns.
Examples
Compares file1.txt and file2.txt and shows the differences.
Shows differences between two C files in unified format.
Compares two config files, ignoring case.
Compares two documents, ignoring all whitespace changes.
Recursively compares the contents of original_dir/ and backup_dir/.
Reports only the names of files that differ between dir1/ and dir2/.
Compares main.py and feature.py side-by-side, only showing differing lines.