Is there a way to color highlight difference while using sdiff?

2.3k Views Asked by At

I'm comparing two files using sdiff to get side by side difference but I want the difference to be color highlighted.
Ex:
File A:
Hello There! General Kenobi!
Magic

File B:
Hello World! Hola
Magic

Now the output from sdiff will be:
Hello There! General Kenobi! | Hello World! Hola

I want the diff highlighted like (couldn't color code so, bold and italics)
Hello There! General Kenobi! | Hello World! Hola

I can't use GUI based or colordiff command etc. I tried using sed and last option is to pipe the sdiff output through a script, but I'm thinking there might be a better way.

2

There are 2 best solutions below

0
On

csdiff is a small wrapper script to colorize the output of sdiff.

It works well for colorizing the side-by-side diff, but it doesn't work with sdiff's interactive mode (-o).

You can also just use diff --color=always --side-by-side for similar results, or icdiff.

0
On

The emacs command ediff-buffers produces colourised output. But you have to be using emacs :-)