CCDIFF(1p)
๐ ccdiff ๐
okay bestie, sit down, hydrate, because this is ccdiff from section 1p of the User Contributed Perl Documentation and she is so much more fun than regular diff. Let's get into it. ๐ฆ
โจ NAME โจ
ccdiff โ Colored Character diff ๐
๐ธ SYNOPSIS ๐ธ
ccdiff [options] file1|- file2|-
ccdiff [options] dir1 dir2
ccdiff --help
ccdiff --man
ccdiff --info
๐ DESCRIPTION ๐
So here's the tea: ccdiff shows you the diff between two files on a character by character base. Unlike the standard diff tools (love them, but they're giving basic), this tool runs the diff algorithm horizontally for every line in the vertical diff, highlighting the actual changes. It's so handy for those changes that are genuinely impossible to spot with your eyeballs, like "O" vs 0, "I" vs l, or 1 and whitespace. ๐ญ
If you hand her two arguments and both of them are a folder/directory, a recursive diff gets executed. This is not available when used as a (sub)class. ๐ซถ
๐ OPTIONS ๐
๐ Command line options ๐
--help,-?โ Shows you a lil summary of all the available command-line options and then dips out (exits). โจ--version,-Vโ Shows the version and exits. slay.--manโ Shows this very manual, rendered viapod2manandnroff.--infoโ Shows this manual too, but viapod2textthis time. same lore, different font bestie.--utf-8,-Uโ All I/O โ that means the streams to compare and standard out โ are in UTF-8. ๐--diff-class=C,--dc=C,--ppโ Picks the class used to actually execute the diff. By default"ccdiff"will grab the first available out of"Algorithm::Diff::XS"or"Algorithm::Diff".
Sometimes the "XS" version just fails on encoding (not her fault) and the pure-perl version will work just fine. So you can force "ccdiff" to use either one:
To select the pure-perl version, pass any of "PP", "AD", "Algorthm::Diff", "Algorithm-Diff", or "Algorithm::Diff::PP" (case insensitive, she does not care about your caps lock). And for convenience, "--dc=pp" can be abbreviated to "--pp". ๐
--pp
--dc=pp
--dc=algorithm-diff
--diff-class=Algorithm::Diff::PP
To select the XS version, pass any of "XS", "ADX", "Algorthm::Diff::XS", or "Algorithm-Diff-XS" (case insensitive again, we stay unbothered). ๐ฅ
--dc=xs
--dc=algorithm-diff-xs
--diff-class=Algorithm::Diff::XS
--unified[=3],-u [3]โ Generates a unified diff. The number of context lines is optional and when you omit it, it defaults to3. Heads up though: currently there is no provision for dealing with overlapping diff chunks, so if the common part between two diff chunks is shorter than twice the number of context lines, some lines may show up twice. ๐
The default is to use traditional diff:
5,5c5,5
< Sat Dec 18 07:00:33 1993,I.O.D.U.,,756194433,1442539
---
> Sat Dec 18 07:08:33 1998,I.O.D.U.,,756194433,1442539
and a unified diff (-u1) would be:
5,5c5,5
Tue Sep 6 05:43:59 2005,B.O.Q.S.,,1125978239,1943341
-Sat Dec 18 07:00:33 1993,I.O.D.U.,,756194433,1442539
+Sat Dec 18 07:08:33 1998,I.O.D.U.,,756194433,1442539
Mon Feb 23 10:37:02 2004,R.X.K.S.,van,1077529022,1654127
--verbose[=1],-v[1]โ Shows an additional line for each old or new section in a change chunk (not for added or deleted lines) that shows the hexadecimal value of each character. If"--utf-8"is in effect, it will show the Unicode character name(s) instead. ๐ง
This is a debugging option, so invisible characters can still be "seen". literally iconic.
"--verbose" accepts an optional verbosity-level. On level 2 and up, all horizontal changes get left-and-right markers inserted so you can see the location of the ZERO WIDTH or invisible characters. With level 3 and up and Unicode enabled, the changed characters will also show the codepoint in hex. ๐
An example of this:
With -Uu0v0:
1,1c1,1
- A BCDE Fg
+ A BcdEFg
With -Uu0v1:
1,1c1,1
- A BCDE Fg
- -- verbose : SPACE, LATIN CAPITAL LETTER C, LATIN CAPITAL LETTER D, SPACE
+ A BcdEFg
+ -- verbose : LATIN SMALL LETTER C, LATIN SMALL LETTER D, ZERO WIDTH SPACE
With -Uu0v2:
1,1c1,1
- A โฑ โฐBโฑCDโฐEโฑ โฐFg
- -- verbose : SPACE, LATIN CAPITAL LETTER C, LATIN CAPITAL LETTER D, SPACE
+ A BโฑcdโฐEโฑโฐFg
+ -- verbose : LATIN SMALL LETTER C, LATIN SMALL LETTER D, ZERO WIDTH SPACE
With -Uu0v3:
1,1c1,1
- A โฑ โฐBโฑCDโฐEโฑ โฐFg
- -- verbose : SPACE (U+000020), LATIN CAPITAL LETTER C (U+000043), LATIN CAPITAL LETTER D (U+000044), SPACE (U+000020)
+ A BโฑcdโฐEโฑโฐFg
+ -- verbose : LATIN SMALL LETTER C (U+000063), LATIN SMALL LETTER D (U+000064), ZERO WIDTH SPACE (U+00200B)
With -Uu0v2 --ascii:
1,1c1,1
- A > <B>CD<E> <Fg
- -- verbose : SPACE, LATIN CAPITAL LETTER C, LATIN CAPITAL LETTER D, SPACE
+ A B>cd<E><Fg
+ -- verbose : LATIN SMALL LETTER C, LATIN SMALL LETTER D, ZERO WIDTH SPACE
The word "verbose" and the character markers will be displayed using the "verbose" color. The characters used for the markers can be defined in your configuration file as "chr_cml" (the character used as marker on the left) and "chr_cmr" (the character used as marker on the right). ๐
--markers,-mโ Puts markers under each changed character in change-chunks. ๐ซถ
"--markers" is especially useful if your terminal does not support colors, or if you want to copy/paste the output into (ASCII) mail. See also "--ascii". The markers will have the same color as added or deleted text.
This will look like (with unified diff):
5,5c5,5
-Sat Dec 18 07:08:33 1998,I.O.D.U.,,756194433,1442539
- โผ โผ
+Sat Dec 18 07:00:33 1993,I.O.D.U.,,756194433,1442539
+ โฒ โฒ
The characters used for the markers can be defined in your configuration file as "chr_old" (the character used as marker under removed characters) and "chr_new" (the character used as marker under added characters).
If"--ellipsis"is also in effect and either the"chr_eli"is longer than one character or"--verbose"level is over2, this option is automatically disabled. ๐
--ascii,-aโ Uses (colored) ASCII indicators instead of Unicode. The default indicators are Unicode characters that stand out better. The markers will have the same color as added or deleted text. โจ
For the vertical markers ("-m") that would look like:
5,5c5,5
-Sat Dec 18 07:08:33 1998,I.O.D.U.,,756194433,1442539
- ^ ^
+Sat Dec 18 07:00:33 1993,I.O.D.U.,,756194433,1442539
+ ^ ^
For the positional indicators, she did consider using U+034e (COMBINING UPWARDS ARROW BELOW), but as most terminals are probably unable to show it due to line height changes, the idea was not pursued. rip to that idea, she was ahead of her time. ๐
--pink,-pโ Changes the default"red"for deleted text to the color closest to pink that is supported byTerm::ANSIColor:"magenta". ๐๐--reverse,-rโ Reverse/invert the foreground and background for the colored indicators.
If the foreground color has "bold", it will be stripped from the new background color.
--swap,-sโ Swaps the colors for new and old. chaos, but make it fashion.--list-colorsโ Lists available colors and exits. ๐--no-colorsโ Disables all colors. Super useful for redirecting the diff output to a file that's gonna be included in documentation. ๐ซถ
This is the default if the environment variable $NO_COLOR has a true value, or if the environment variable $CLICOLOR is set to a false value. If set, $CLICOLOR_FORCE will overrule the default of $NO_COLOR.
--old=colorโ Defines the foreground color for deleted text.--new=colorโ Defines the foreground color for added text.--bg=colorโ Defines the background color for changed text.--index,--idx,-Iโ Prefixes position indicators with an index. ๐ฅ
[001] 5,5c5,5
-Sat Dec 18 07:08:33 1998,I.O.D.U.,,756194433,1442539
+Sat Dec 18 07:00:33 1993,I.O.D.U.,,756194433,1442539
If a positive number is passed ("--index=4" or "-I 4"), display just the chunk with that index, using the "verbose" color.
This is useful in combination with "--verbose".
--threshold=2,-t 2โ Defines the number of lines a change block may differ before the fall-back of horizontal diff to vertical diff.
If a chunk describes a change, and the number of lines in the original block has fewer or more lines than the new block, and that difference exceeds this threshold, "ccdiff" will fall-back to vertical diff. ๐ญ
--heuristics=n,-h nโ Defines the percentage of character-changes a change block may differ before the fall-back of horizontal diff to vertical diff.
This percentage is calculated as "(characters removed + characters added) / (2 * characters unchanged))". math girlies rise. ๐
--ellipsis=n,-e nโ Defines the number of characters to keep on each side of a horizontal-equal segment. The default is0, meaning do not compress. ๐ฆ
If set to a positive number, and the length of a segment of equal characters inside a horizontal diff is longer than twice this value, the middle part is replaced with "โ U02508 \N{BOX DRAWINGS LIGHT QUADRUPLE DASH HORIZONTAL}" (instead of โฆ U02026, as HORIZONTAL ELLIPSIS does not stand out enough). periodt.
With "-u0me3" that would be like:
5,5c5,5
-Satโ07:08:33โ 1998,I.โ539
- โผ โผ
+Satโ07:00:33โ 1993,I.โ539
+ โฒ โฒ
With "-u0e3 -v2" like:
5,5c5,5
-Satโค9โฆ07:0โฑ0โฐ:33 199โฑ3โฐ,I.โค23โฆ539
- -- verbose : DIGIT ZERO, DIGIT THREE
+Satโค9โฆ07:0โฑ8โฐ:33 199โฑ8โฐ,I.โค23โฆ539
+ -- verbose : DIGIT EIGHT, DIGIT EIGHT
The text used for the replaced text can be defined in your configuration file as "chr_eli" and/or "chr_eli_v". ๐
--ignore-case,-iโ Ignores case on comparison. we love an unbothered queen.--ignore-all-space,-wโ Ignores all white-space changes. This will set all the options"-b","-Z","-E", and"-B". โจ--ignore-trailing-space,-Zโ Ignores changes in trailing white-space (tabs and spaces).--ignore-ws|ignore-space-change,-bโ Ignores changes in horizontal white-space (tabs and spaces). This does not include white-space changes that split non-white-space, or remove white-space between two non-white-space elements.--ignore-tab-expansion,-Eโ NYI. (not yet implemented bestie, she's still cooking ๐)--ignore-blank-lines,-Bโ Just Partly Implemented (WIP). ๐
๐ Configuration files ๐
So in order to be able to overrule the defaults set in "ccdiff", you can set options specific for this login. The following option files are looked for, in this exact order:
$HOME/ccdiff.rc$HOME/.ccdiffrc$HOME/.config/ccdiff
and they're evaluated in that order too. Any options specified in a file later in that chain will overwrite previously set options. last one wins, that's the rule. ๐
Option files are only read and evaluated if they are not empty and not writable by others than the owner. ๐
(part 1 done, more coming, don't go anywhere bestie ๐ซถ)
okay so the config file itself? one option per line, and leading + trailing white-space gets ignored, periodt. ๐
If a line starts with one of the options below, followed by optional white-space, followed by either an = or a :, followed by optional white-space and then the values โ boom, the value gets assigned to that option. โจ
And the value aliases, bestie, write these down:
noandfalse(case insensitive) are aliases for0yesandtrueare aliases for-1(and-1is a true value)
Also, anything in parens next to an option name is the corresponding command-line option. iykyk ๐ซถ
unified(-u) โ if you're an old-style-diff hater and want unified-diff by default, set this to however many context lines you want:
unified : 3
The default is undefined. ๐
markers(-m) โ
markers : false
This one defines if markers should be used under changed characters. Default vibe is colors only. The -m command line option will toggle the option when set from a configuration file.
ascii(-a) โ
ascii : false
Defines whether to use ASCII markers instead of Unicode markers. Default is Unicode markers. ๐ฆ
reverse(-r) โ
reverse : false
Defines if changes are displayed as foreground-color over background-color, or background-color over foreground-color. The default is "false", so it colors the changes with the appropriate color ("new" or "old") over the default background color. ๐
swap(-s) โ
swap : false
Swaps the colors for new and old. chaos, but make it fashion ๐
new(--new) โ
new : green
Defines the color used for added text. Default is "green".
The color "none" is also accepted and disables this color.
Any color accepted by Term::ANSIColor is allowed. Any other color will result in a warning. This option can include "bold" either as prefix or as suffix.
This option may also be specified as
new-color
new_color
new-colour
new_colour
old(--old) โ
old : red
Defines the color used for deleted text. Default is "red".
The color "none" is also accepted and disables this color.
Any color accepted by Term::ANSIColor is allowed. Any other color will result in a warning. This option can include "bold" either as prefix or as suffix.
This option may also be specified as
old-color
old_color
old-colour
old_colour
bg(--bg) โ
bg : white
Defines the color used as background for changed text. Default is "white".
The color "none" is also accepted and disables this color.
Any color accepted by Term::ANSIColor is allowed. Any other color will result in a warning. The "bold" attribute is not allowed. ๐
This option may also be specified as
bg-color
bg_color
bg-colour
bg_colour
background
background-color
background_color
background-colour
background_colour
header(-H,--header,--HC=color,--header-color=color) โ
header : 1
header : blue_on_white
Defines if a header is displayed above the diff (default is 1), and supported colors are allowed. ๐
If the value is a valid supported color, it'll show the header in that color scheme. To disable the header, set it to 0 in the RC file or use --no-header as a command line argument.
old-labelnew-label
These define the tag(s) in the header for the source file(s)/stream(s). ๐ท๏ธ
App::ccdiff::ccdiff ($left, $right);
=>
< *STDIN Fri Nov 7 10:14:51 2025
> *STDIN Fri Nov 7 10:14:51 2025
App::ccdiff::ccdiff ($left, $right,
{ "old-label" => "OLD", "new-label" => "NEW" });
=>
< OLD Fri Nov 7 10:14:51 2025
> NEW Fri Nov 7 10:14:51 2025
verboseโ
verbose : cyan
Defines the color used for the verbose tag. Default is "cyan". This color will only be used under --verbose. โจ
The color "none" is also accepted and disables this color.
Any color accepted by Term::ANSIColor is allowed. Any other color will result in a warning.
This option may also be specified as
verbose-color
verbose_color
verbose-colour
verbose_colour
utf8(-U) โ
utf8 : yes
Defines whether all I/O is to be interpreted as UTF-8. The default is "no". ๐ธ
This option may also be specified as
unicode
utf
utf-8
index(-I) โ
index : no
Defines if the position indication for a change chunk is prefixed with an index number. The default is "no". The index is 1-based.
Without this option, the position indication would be like
5,5c5,5
19,19d18
42a42,42
with this option, it would be
[001] 5,5c5,5
[002] 19,19d18
[005] 42a42,42
When this option contains a positive integer, ccdiff will only show the diff chunk with that index. ๐ฏ
emacsโ
emacs : no
If this option is yes/true, calling ccdiff with just one single argument, and that argument being an existing file, the arguments will act as
$ ccdiff file~ file
if file~ exists.
threshold(-t) โ
threshold : 2
Defines the number of lines a change block may differ before the fall-back of horizontal diff to vertical diff. ๐
heuristics(-h) โ
heuristics : 40
Defines the percentage of character-changes a change block may differ before the fall-back of horizontal diff to vertical diff. The default is undefined, meaning no fallback based on heuristics.
ellipsis(-e) โ
ellipsis : 0
Defines the number of characters to keep on each side of a horizontal-equal segment. The default is 0, meaning to not compress. See also "chr_eli".
chr_oldโ
chr_old : U+25BC
Defines the character used to indicate the position of removed text on the line below the text when option -m is in effect. ๐ป
chr_newโ
chr_new : U+25B2
Defines the character used to indicate the position of added text on the line below the text when option -m is in effect. ๐บ
chr_cmlโ
chr_cml : U+21B1
Defines the character used to indicate the starting position of changed text in a line when verbose level is 3 and up.
chr_cmrโ
chr_cmr : U+21B0
Defines the character used to indicate the ending position of changed text in a line when verbose level is 3 and up.
chr_eliโ
chr_eli : U+2508
Defines the character used to indicate omitted text in large unchanged text when --ellipsis/-e is in effect.
Heads up bestie: this character is not equally well visible on all terminals or in all fonts, so you might wanna change it to something that stands out better in your environment. ๐
Possible suggestions:
โฆ U+2026 HORIZONTAL ELLIPSIS
โด U+2034 TRIPLE PRIME
โท U+2037 REVERSED TRIPLE PRIME
โ U+2194 LEFT RIGHT ARROW
โญ U+21ad LEFT RIGHT WAVE ARROW
โฎ U+21ae LEFT RIGHT ARROW WITH STROKE
โน U+21b9 LEFTWARDS ARROW TO BAR OVER RIGHTWARDS ARROW TO BAR
โ U+21c4 RIGHTWARDS ARROW OVER LEFTWARDS ARROW
โ U+21c6 LEFTWARDS ARROW OVER RIGHTWARDS ARROW
โ U+21ce LEFT RIGHT DOUBLE ARROW WITH STROKE
โ U+21d4 LEFT RIGHT DOUBLE ARROW
โน U+21f9 LEFT RIGHT ARROW WITH VERTICAL STROKE
โผ U+21fc LEFT RIGHT ARROW WITH DOUBLE VERTICAL STROKE
โฟ U+21ff LEFT RIGHT OPEN-HEADED ARROW
โ U+224b TRIPLE TILDE
โ U+2504 BOX DRAWINGS LIGHT TRIPLE DASH HORIZONTAL
โ
U+2505 BOX DRAWINGS HEAVY TRIPLE DASH HORIZONTAL
โ U+2508 BOX DRAWINGS LIGHT QUADRUPLE DASH HORIZONTAL
โ U+2509 BOX DRAWINGS HEAVY QUADRUPLE DASH HORIZONTAL
โงป U+29fb TRIPLE PLUS
โฌ U+2b0c LEFT RIGHT BLACK ARROW
chr_eli_vโ
chr_eli_v : U+21A4U+21A6
When using --ellipsis with --verbose level 2 or up, the single character indicator gets replaced with this character. If it's 2 characters wide, the length of the compressed part is put between the characters.
A suggested alternative might be U+21E4U+21E5. ๐ซถ
iwbZusePPโ so here's the tea: Algorithm::Diff::XS is fast but is not 100% drop-in compliant with Algorithm::Diff, and options-i,-w,-b, and-Zare likely to not work in theXSversion. This option lets you automatically switch to the slower version if any of those options is selected. ๐
๐ Git integration โจ
You can use ccdiff to show diffs in git. It may work like this: ๐
$ git config --global diff.tool ccdiff
$ git config --global difftool.prompt false
$ git config --global difftool.ccdiff.cmd 'ccdiff --utf-8 -u -r $LOCAL $REMOTE'
$ git difftool SHA~..SHA
$ wget https://github.com/Tux/App-ccdiff/raw/master/Files/git-ccdiff \
-O ~/bin/git-ccdiff
$ perl -pi -e 's{/pro/bin/perl}{/usr/bin/env perl}' ~/bin/git-ccdiff
$ chmod 755 ~/bin/git-ccdiff
$ git ccdiff SHA
Of course you can use curl instead of wget and you can choose your own (fixed) path to perl instead of using /usr/bin/env. no cap
From then on you can do
$ git ccdiff
$ git ccdiff 5c5a39f2
๐ CAVEATS ๐
Due to the implementation, where both sides of the comparison are completely kept in memory, this tool might not be able to deal with (very) large datasets. ๐ญ
๐๏ธ Speed ๐๏ธ
There are situations where Algorithm::Diff takes considerably more time compared to e.g. GNU diff. Installing Algorithm::Diff::XS will make ccdiff a lot faster. ccdiff will choose Algorithm::Diff::XS if available.
Note however that options like -i, -w, -b, and -Z are likely to be a no-op in Algorithm::Diff::XS, as that has not been implemented and it is rather unlikely it will be. Choose --dc=pp then. If you want this switch always, set iwbZusePP = 1 in one of your Configuration files. โจ
๐ฆ SEE ALSO ๐ฆ
Algorithm::Diff::XS, Algorithm::Diff, Text::Diff
๐ AUTHOR ๐
H.Merijn Brand
๐ COPYRIGHT AND LICENSE ๐
Copyright (C) 2018-2026 H.Merijn Brand. All rights reserved.
This library is free software; you can redistribute and/or modify it under the same terms as The Artistic License 2.0.
and that's the whole page bestie, we ate and left no crumbs ๐
โจ this iconic little manual was brought to you by perl v5.40.1 and is dated 2026-01-29 โ go forth and diff pretty, CCDIFF(1p) out ๐ซถ๐
๐ฆ where this page comes from
- ubuntu resolute: ccdiff 0.35-1 ยท Artistic-2.0
- ubuntu stonking: ccdiff 0.35-1 ยท Artistic-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms