What is the diff Command in Linux?
The diff
command in Linux is a powerful tool for comparing files. It displays the differences between two files line by line, showing the changes that would need to be made to one file to make it identical to the other. It is widely used in development for tracking changes between versions of code files or configuration files.
Basic syntax:
diff [option] file1 file2
Compare two files:
diff file1.txt file2.txt
Options
Option | Description |
---|---|
-c | Output NUM (default 3) lines of copied context |
-u | Output NUM (default 3) lines of unified context |
-i | Ignores case differences |
-r | Recursively compares directories |
-w | Ignores all white space differences |
-y | Outputs a side-by-side comparison |
Additional Help
You can explore more by using the commands:
diff --help
# or
man diff
Thank you!
Thank you for your time and for reading this!