Linux: diff, Compare Files/Dirs
Compare Binary Files
cmp file1 file2
-
If 2 files have same content, there is no output. Else it'll print the first byte count that's different.
Sample output:
file1 file2 differ: byte 174, line 4
Find Difference Between 2 Text Files
diff file1 file2
-
show difference between text files.
Most useful options of
diff
:-i
or--ignore-case
-E
or--ignore-tab-expansion
-b
or--ignore-space-change
-w
or--ignore-all-space
-B
or--ignore-blank-lines
--strip-trailing-cr
Find Difference Between Directories
diff -r --brief dirpath1 dirpath2
-
compare 2 directories, show only missing files/dir
-r
means recurvise (all subdirs)--brief
means only output if files differ (as opposed to how they differ) or non-existant.