diff – Compare files line by line

Syntax

diff {option} file_1 file_2

The diff tool for compares two text files line by line and calculates the differences between them. That difference file is called a patch and can by applied to the first text file to transform it into the second one using the patch tool.

Options include

-B, --ignore-blank-lines
Ignore changes whose lines are all blank.
-b, --ignore-space-change
Ignore changes in the amount of white space.
-I regex, --ignore-matching-lines=regex
Ignore changes whose lines all match the regular expression regex.
-i, --ignore-case
Ignore case differences in file contents.
-s, --report-identical-files
Report when two files are the same.
-y, --side-by-side
Output in two columns.
-W number, --width=number
Output at most number print columns (default is 130).
--suppress-common-lines
Do not output common lines.

Examples

See the examples of usage given at the Process substitution page. In addition:

# compare two checksum manifests, generated by the '-f framemd5' option of
# 'ffmpeg', and print the differing MD5 values

diff --side-by-side --width=80 --suppress-common-lines
     <(cat file_1 | cut -d, -f 6)
     <(cat file_2 | cut -d, -f 6)

Further information

man diff


2022-07-01