Here are some common options for the diff command that are frequently used:
-
-u: Unified format output, which shows a few lines of context around the differences.diff -u file1.txt file2.txt -
-c: Context format output, providing more context around the differences than the default output.diff -c file1.txt file2.txt -
-r: Recursively compare directories and their contents.diff -r dir1 dir2 -
-i: Ignore case differences in the file contents.diff -i file1.txt file2.txt -
-w: Ignore all white space when comparing lines.diff -w file1.txt file2.txt -
-q: Report only whether the files differ, without showing the actual differences.diff -q file1.txt file2.txt -
-y: Display the differences side by side.diff -y file1.txt file2.txt -
--suppress-common-lines: When used with-y, this option suppresses lines that are the same in both files.diff -y --suppress-common-lines file1.txt file2.txt
These options can be combined to customize the output according to your needs. For example:
diff -urN dir1 dir2
This command will recursively compare dir1 and dir2, treating absent files as empty and providing a unified output format.
