Skip to content
Latchkey

sdiff: Side-by-Side Diff and Interactive Merge

sdiff prints two files in side-by-side columns with change markers between them and can drive an interactive line-by-line merge.

sdiff ships with GNU diffutils and is handy when you want a two-column view without installing anything extra. The middle gutter shows which side changed.

What it does

sdiff compares two files and prints them side by side. A marker in the center column shows the relationship: < for a line only in the left file, > for the right, and | for a changed line. With -o it enters an interactive merge, writing the resolved result to the named file. Exit status follows diff.

Common usage

Terminal
sdiff old.conf new.conf
# suppress identical lines, set a wider layout
sdiff -s -w 200 old.conf new.conf
# interactive merge into a result file
sdiff -o merged.conf old.conf new.conf

Options

FlagWhat it does
-sSuppress lines that are common to both files
-w <n>Set the total output width
-o <file>Interactive merge, writing the result to file
-lShow only the left column for common lines
-i / -WIgnore case / ignore whitespace

In CI

For non-interactive logs use sdiff -s -w <width> to print a compact side-by-side view of what changed; skip -o, which requires a human at the keyboard. It is a display aid, so gate the build on diff or git diff, not on sdiff.

Common errors in CI

If a job hangs, it is almost certainly sdiff -o waiting for interactive merge input; never use -o in CI. Columns that overflow or wrap mean the -w width exceeds the log width; pin a fixed -w. sdiff exits 1 when the files differ, which is a difference, not an error.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →