Exploring diff - Linux Commands

| 2 min read

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

OptionDescription
-cOutput NUM (default 3) lines of copied context
-uOutput NUM (default 3) lines of unified context
-iIgnores case differences
-rRecursively compares directories
-wIgnores all white space differences
-yOutputs 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!