Copied to clipboard

diff

`diff` compares the contents of two files line by line. It can also compare directories. By default, `diff` shows you all the lines that are different between the two files. You can use options to get more specific output.

Examples

  • Compare two files: diff file1 file2
  • Compare all files in two directories: diff -r directory1 directory2
  • Ignore trailing white space and blank lines: diff -bB file1 file2
  • Output file differences in context: diff -c file1 file2
  • Output file differences in context, specify lines of context: diff -C 3 file1 file2
  • Ignore case differences in file contents: diff -i file1 file2
  • Ignore all white space: diff -w file1 file2
  • Report only when files are different: diff -s file1 file2