Sh - File Diff (diff, sdiff)

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU)

1 - About

3 - Files

3.1 - File 1

Same Line
Same Line 2
Different Line

3.2 - File 2

Same Line
New Line
Same Line 2
Different Line :)

4 - Diff

4.1 - Unified

diff file1.txt file2.txt
1a2
> New Line
3c4
< Different Line
---
> Different Line :)

Diff command point to which lines need to be:

  • Added (a)
  • Deleted (d)
  • Changed (c)

Symbol:

  • less than (<) symbol: Line must be suppressed ?
  • greater than (>) symbol: New Line
Advertising

4.2 - Side by Side

Sdiff runs diff with the side-by-side options.

sdiff file1.txt file2.txt
Same Line                                                       Same Line
                                                              > New Line
Same Line 2                                                     Same Line 2
Different Line                                                | Different Line :)