xref: /freebsd/usr.bin/sdiff/sdiff.1 (revision f9bc005b8ef3b507a5ecbc2d7fe4411ef70eff38)
1.\" $OpenBSD: sdiff.1,v 1.15 2007/06/29 14:48:07 jmc Exp $
2.\"
3.\" Written by Raymond Lai <ray@cyth.net>.
4.\" Public domain.
5.\"
6.Dd September 23, 2026
7.Dt SDIFF 1
8.Os
9.Sh NAME
10.Nm sdiff
11.Nd side-by-side diff
12.Sh SYNOPSIS
13.Nm
14.Op Fl abdilstHW
15.Op Fl I Ar regexp
16.Op Fl o Ar outfile
17.Op Fl w Ar width
18.Ar file1
19.Ar file2
20.Nm sdiff
21.Fl -help
22.Sh DESCRIPTION
23.Nm
24displays two files side by side,
25with any differences between the two highlighted as follows:
26new lines are marked with
27.Sq \*(Gt ;
28deleted lines are marked with
29.Sq \*(Lt ;
30and changed lines are marked with
31.Sq \*(Ba .
32.Pp
33.Nm
34can also be used to interactively merge two files,
35prompting at each set of differences.
36See the
37.Fl o
38option for an explanation.
39.Pp
40The options are:
41.Bl -tag -width Ds
42.It Fl l -left-column
43Only print the left column for identical lines.
44.It Fl o -output Ar outfile
45Interactively merge
46.Ar file1
47and
48.Ar file2
49into
50.Ar outfile .
51In this mode, the user is prompted for each set of differences.
52See
53.Ev EDITOR
54and
55.Ev VISUAL ,
56below,
57for details of which editor, if any, is invoked.
58.Pp
59The commands are as follows:
60.Bl -tag -width Ds
61.It Cm l | 1
62Choose left set of diffs.
63.It Cm r | 2
64Choose right set of diffs.
65.It Cm s
66Silent mode \(en identical lines are not printed.
67.It Cm v
68Verbose mode \(en identical lines are printed.
69.It Cm e
70Start editing an empty file, which will be merged into
71.Ar outfile
72upon exiting the editor.
73.It Cm e Cm l
74Start editing file with left set of diffs.
75.It Cm e Cm r
76Start editing file with right set of diffs.
77.It Cm e Cm b
78Start editing file with both sets of diffs.
79.It Cm q
80Quit
81.Nm .
82.El
83.It Fl s -suppress-common-lines
84Skip identical lines.
85.It Fl w -width Ar width
86Print a maximum of
87.Ar width
88characters on each line.
89The default is 130 characters.
90.It Fl -help
91Print the usage message and exit.
92.El
93.Pp
94Options passed to
95.Xr diff 1
96are:
97.Bl -tag -width Ds
98.It Fl a -text
99Treat
100.Ar file1
101and
102.Ar file2
103as text files.
104.It Fl b -ignore-space-change
105Ignore trailing blank spaces.
106.It Fl d -minimal
107Minimize diff size.
108.It Fl I -ignore-matching-lines Ar regexp
109Ignore line changes matching
110.Ar regexp .
111All lines in the change must match
112.Ar regexp
113for the change to be ignored.
114.It Fl i -ignore-case
115Do a case-insensitive comparison.
116.It Fl t -expand-tabs
117Expand tabs to spaces.
118.It Fl W -ignore-all-space
119Ignore all spaces.
120.It Fl B -ignore-blank-lines
121Ignore blank lines.
122.It Fl E -ignore-tab-expansion
123Treat tabs and eight spaces as the same.
124.It Fl H -speed-large-files
125Assume scattered small changes in a large file.
126.It Fl -ignore-file-name-case
127Ignore the case of file names.
128.It Fl -no-ignore-file-name-case
129Do not ignore file name case.
130.It Fl -strip-trailing-cr
131Skip identical lines.
132.It Fl -tabsize Ar NUM
133Change the size of tabs (default is 8.)
134.El
135.Sh ENVIRONMENT
136.Bl -tag -width Ds
137.It Ev EDITOR , VISUAL
138Specifies an editor to use with the
139.Fl o
140option.
141If both
142.Ev EDITOR
143and
144.Ev VISUAL
145are set,
146.Ev VISUAL
147takes precedence.
148If neither
149.Ev EDITOR
150nor
151.Ev VISUAL
152are set,
153the default is
154.Xr vi 1 .
155.It Ev TMPDIR
156Specifies a directory for temporary files to be created.
157The default is
158.Pa /tmp .
159.El
160.Sh EXIT STATUS
161The
162.Nm
163utility exits with one of the following values:
164.Pp
165.Bl -tag -width Ds -offset indent -compact
166.It 0
167No differences were found.
168.It 1
169Differences were found.
170.It >1
171An error occurred.
172.El
173.Pp
174The
175.Fl -help
176option exits with a status of 0.
177.Sh SEE ALSO
178.Xr cmp 1 ,
179.Xr diff 1 ,
180.Xr diff3 1 ,
181.Xr vi 1 ,
182.Xr re_format 7
183.Sh AUTHORS
184.Nm
185was written from scratch for the public domain by
186.An Ray Lai Aq Mt ray@cyth.net .
187.Sh CAVEATS
188Tabs are treated as anywhere from one to eight characters wide,
189depending on the current column.
190Terminals that treat tabs as eight characters wide will look best.
191