Linux Views 5

Comparing files with the Linux diff command

Comparing files with the Linux diff command image 1

The diff file-comparison command


diff is short for differences, and it is a command that compares the contents of two files or folders.
It reports the result intuitively and clearly, and it shows the line-by-line changes in document files.

Command options

  • -b : ignore sequences of whitespace
  • -c : print the differences between the two files
  • -d : print the differences between the two files in detail
  • -r : print the differences between two directories, comparing subdirectories as well
  • -i : ignore differences in case
  • -w : ignore all whitespace differences
  • -s : report when the two files are the same
  • -u : also print the nearby content around the parts that change in the two files
  • -t : put TAB characters in the output lines
  • --brief : show the result after comparing the files
  • -q : print only the differences between the two files

By comparing two files, you can see how a file has changed.

Reactions

Comments 0

A nickname and a password are required. The same password edits or deletes the comment later. Comments appear after a review.

Comments appear after a review. The password is used again to edit or delete.