diff

>Usage

The diff command is used to compare the contents of two files line by line. It outputs differences to help identify changes, especially useful in code review, configuration file comparison, and text comparison.

>Syntax

diff [options] file1 file2

>Options

-u

Shows differences in a more readable, unified format.

-c

Shows differences with context around the changes.

-i

Ignores case differences in text comparison.

-w

Ignores all white space in text comparison.

--side-by-side

Displays the output in a side-by-side comparison format.

>Examples

Example 1:

Dots

-zsh

> diff file1.txt file2.txt


3c3 (This is a line in file1)
--- (This is a different line in file2)

Example 2:

Dots

-zsh

> diff --side-by-side file1.txt file2.txt


Line one (in file1) Line one (in file2, which is the same as Line One in file1)
Line two (in file1) | Line two (in file2, different from Line Two in file1)

>Quiz

Progress: Question ? out of ?

Question Title

Page written by Gokhan YILMAZ