difference(1)

difference1

Compares two strings and prints a colorful diff

Usage

difference [--split split] orig edit

Overview

difference compares the strings orig and edit and prints a colorful representation of the difference to the standard output.

Options

-s, --split char|word|line

Select the level of detail in the diff (default: word).

Examples

In the examples, text that would be printed in red is formatted in italics, and text that would be printed in green is formatted bold.

Compare characters:
$ difference --split char brown green
bgroween

Compare words:
$ difference --split word brown green
brown green

$ difference --split word "The quick brown fox jumps over the lazy dog." "The huge brown fox is cool."
The quick huge brown fox jumps over the lazy dog. is really cool.

Compare lines:
$ difference --split word brown green
brown
green

$ difference --split word "The quick brown fox jumps over the lazy dog." "The huge brown fox is cool."
The quick brown fox jumps over the lazy dog.
The huge brown fox is cool.

$ difference --split line "Roses are red, violets are blue,
> I wrote this library here,
> just for you.
> (It's true)." "Roses are red, violets are blue,
> I wrote this documentation here,
> just for you.
> (It's quite true)."
Roses are red, violets are blue,
I wrote this library here,
I wrote this documentation here,
just for you.
(It's true).
(It's quite true).

Releases

Unchanged in 4 releases since Debian 10 (Buster).

  1. 10–13

From difference 2.0.0-1+b14 in Debian 13 (Trixie). Parsed by carta from the page's man source.