sdiff
Side-by-side file comparison and merge
TLDR
SYNOPSIS
sdiff [-o output] [-w width] [-sbBiW] [options] file1 file2
DESCRIPTION
sdiff compares two files side by side. It displays corresponding lines in parallel columns, marking differences with symbols.Output symbols indicate relationship: blank (identical), | (different), < (only in left), > (only in right). This visual format makes differences immediately apparent.Interactive merge mode (-o) creates a combined file from the two inputs. At each difference, you choose: left (l), right (r), edit left (el), edit right (er), or both (b). This enables manual resolution of differences.Width setting (-w) controls output columns. Narrow widths truncate lines; wider widths show more content. Terminal width is commonly used (e.g., -w 80 or -w $COLUMNS).Suppressing common lines (-s) shows only differences, useful for focusing on changes in files that are mostly identical.Whitespace and case options help compare files with formatting differences that aren't substantive.
PARAMETERS
-o FILE, --output FILE
Interactive merge to output file.-w NUM, --width NUM
Output width in columns.-s, --suppress-common-lines
Don't show identical lines.-l, --left-column
Show only left column for common lines.-b, --ignore-space-change
Ignore changes in whitespace amount.-B, --ignore-blank-lines
Ignore blank line changes.-i, --ignore-case
Case-insensitive comparison.-W, --ignore-all-space
Ignore all whitespace.-t, --expand-tabs
Expand tabs to spaces.--strip-trailing-cr
Strip trailing carriage returns.-a, --text
Treat all files as text.-d, --minimal
Find minimal set of changes.-H, --speed-large-files
Heuristics for large files.
CAVEATS
Binary files display poorly. Very long lines may be truncated. Interactive mode requires terminal. Wide files need wide terminal or scrolling. Not as feature-rich as diff for scripting.
HISTORY
sdiff is part of GNU diffutils, developed by the Free Software Foundation. Side-by-side diff originated in Unix research, providing visual comparison before graphical diff tools existed. The GNU version added interactive merge mode and various comparison options.
