xref: /freebsd/usr.bin/diff/diff.1 (revision 63613e3ba1e188e9fece43e1613bd697f04b345e)
1.\" $OpenBSD: diff.1,v 1.47 2015/11/24 19:35:41 jmc Exp $
2.\"
3.\" Copyright (c) 1980, 1990, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.Dd March 7, 2024
31.Dt DIFF 1
32.Os
33.Sh NAME
34.Nm diff
35.Nd differential file and directory comparator
36.Sh SYNOPSIS
37.Nm diff
38.Op Fl aBbdipTtw
39.Oo
40.Fl c | e | f |
41.Fl n | q | u | y
42.Oc
43.Op Fl A Ar algo | Fl -algorithm Ar algo
44.Op Fl -brief
45.Op Fl -color Ns = Ns Ar when
46.Op Fl -changed-group-format Ar GFMT
47.Op Fl -ed
48.Op Fl -expand-tabs
49.Op Fl -forward-ed
50.Op Fl -ignore-all-space
51.Op Fl -ignore-case
52.Op Fl -ignore-space-change
53.Op Fl -initial-tab
54.Op Fl -minimal
55.Op Fl -no-ignore-file-name-case
56.Op Fl -normal
57.Op Fl -rcs
58.Op Fl -show-c-function
59.Op Fl -starting-file
60.Op Fl -speed-large-files
61.Op Fl -strip-trailing-cr
62.Op Fl -tabsize Ar number
63.Op Fl -text
64.Op Fl -unified
65.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern
66.Op Fl F Ar pattern | Fl -show-function-line Ar pattern
67.Op Fl L Ar label | Fl -label Ar label
68.Ar file1 file2
69.Nm diff
70.Op Fl aBbdilpTtw
71.Op Fl A Ar algo | Fl -algorithm Ar algo
72.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern
73.Op Fl F Ar pattern | Fl -show-function-line Ar pattern
74.Op Fl L Ar label | Fl -label Ar label
75.Op Fl -brief
76.Op Fl -color Ns = Ns Ar when
77.Op Fl -changed-group-format Ar GFMT
78.Op Fl -ed
79.Op Fl -expand-tabs
80.Op Fl -forward-ed
81.Op Fl -ignore-all-space
82.Op Fl -ignore-case
83.Op Fl -ignore-space-change
84.Op Fl -initial-tab
85.Op Fl -minimal
86.Op Fl -no-ignore-file-name-case
87.Op Fl -normal
88.Op Fl -paginate
89.Op Fl -rcs
90.Op Fl -show-c-function
91.Op Fl -speed-large-files
92.Op Fl -starting-file
93.Op Fl -strip-trailing-cr
94.Op Fl -tabsize Ar number
95.Op Fl -text
96.Fl C Ar number | -context Ar number
97.Ar file1 file2
98.Nm diff
99.Op Fl aBbdiltw
100.Op Fl A Ar algo | Fl -algorithm Ar algo
101.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern
102.Op Fl -brief
103.Op Fl -color Ns = Ns Ar when
104.Op Fl -changed-group-format Ar GFMT
105.Op Fl -ed
106.Op Fl -expand-tabs
107.Op Fl -forward-ed
108.Op Fl -ignore-all-space
109.Op Fl -ignore-case
110.Op Fl -ignore-space-change
111.Op Fl -initial-tab
112.Op Fl -minimal
113.Op Fl -no-ignore-file-name-case
114.Op Fl -normal
115.Op Fl -paginate
116.Op Fl -rcs
117.Op Fl -show-c-function
118.Op Fl -speed-large-files
119.Op Fl -starting-file
120.Op Fl -strip-trailing-cr
121.Op Fl -tabsize Ar number
122.Op Fl -text
123.Fl D Ar string | Fl -ifdef Ar string
124.Ar file1 file2
125.Nm diff
126.Op Fl aBbdilpTtw
127.Op Fl A Ar algo | Fl -algorithm Ar algo
128.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern
129.Op Fl F Ar pattern | Fl -show-function-line Ar pattern
130.Op Fl L Ar label | Fl -label Ar label
131.Op Fl -brief
132.Op Fl -color Ns = Ns Ar when
133.Op Fl -changed-group-format Ar GFMT
134.Op Fl -ed
135.Op Fl -expand-tabs
136.Op Fl -forward-ed
137.Op Fl -ignore-all-space
138.Op Fl -ignore-case
139.Op Fl -ignore-space-change
140.Op Fl -initial-tab
141.Op Fl -minimal
142.Op Fl -no-ignore-file-name-case
143.Op Fl -normal
144.Op Fl -paginate
145.Op Fl -rcs
146.Op Fl -show-c-function
147.Op Fl -speed-large-files
148.Op Fl -starting-file
149.Op Fl -strip-trailing-cr
150.Op Fl -tabsize Ar number
151.Op Fl -text
152.Fl U Ar number | Fl -unified Ar number
153.Ar file1 file2
154.Nm diff
155.Op Fl aBbdilNPprsTtw
156.Oo
157.Fl c | e | f |
158.Fl n | q | u
159.Oc
160.Op Fl A Ar algo | Fl -algorithm Ar algo
161.Op Fl -brief
162.Op Fl -color Ns = Ns Ar when
163.Op Fl -changed-group-format Ar GFMT
164.Op Fl -context
165.Op Fl -ed
166.Op Fl -expand-tabs
167.Op Fl -forward-ed
168.Op Fl -ignore-all-space
169.Op Fl -ignore-case
170.Op Fl -ignore-space-change
171.Op Fl -initial-tab
172.Op Fl -minimal
173.Op Fl -new-file
174.Op Fl -no-ignore-file-name-case
175.Op Fl -normal
176.Op Fl -paginate
177.Op Fl -rcs
178.Op Fl -recursive
179.Op Fl -report-identical-files
180.Op Fl -show-c-function
181.Op Fl -speed-large-files
182.Op Fl -strip-trailing-cr
183.Op Fl -tabsize Ar number
184.Op Fl -text
185.Op Fl -unidirectional-new-file
186.Op Fl -unified
187.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern
188.Op Fl F Ar pattern | Fl -show-function-line Ar pattern
189.Bk -words
190.Op Fl L Ar label | Fl -label Ar label
191.Op Fl S Ar name | Fl -starting-file Ar name
192.Op Fl X Ar file | Fl -exclude-from Ar file
193.Op Fl x Ar pattern | Fl -exclude Ar pattern
194.Ek
195.Ar dir1 dir2
196.Nm diff
197.Op Fl aBbditwW
198.Op Fl -color Ns = Ns Ar when
199.Op Fl -expand-tabs
200.Op Fl -ignore-all-blanks
201.Op Fl -ignore-blank-lines
202.Op Fl -ignore-case
203.Op Fl -minimal
204.Op Fl -no-ignore-file-name-case
205.Op Fl -strip-trailing-cr
206.Op Fl -suppress-common-lines
207.Op Fl -tabsize Ar number
208.Op Fl -text
209.Op Fl -width
210.Fl y | Fl -side-by-side
211.Ar file1 file2
212.Nm diff
213.Op Fl -help
214.Op Fl -version
215.Sh DESCRIPTION
216The
217.Nm
218utility compares the contents of
219.Ar file1
220and
221.Ar file2
222and writes to the standard output the list of changes necessary to
223convert one file into the other.
224No output is produced if the files are identical.
225.Pp
226Output options (mutually exclusive):
227.Bl -tag -width Ds
228.It Fl C Ar number Fl -context Ar number
229Like
230.Fl c
231but produces a diff with
232.Ar number
233lines of context.
234.It Fl c
235Produces a diff with 3 lines of context.
236With
237.Fl c
238the output format is modified slightly:
239the output begins with identification of the files involved and
240their creation dates and then each change is separated
241by a line with fifteen
242.Li * Ns 's .
243The lines removed from
244.Ar file1
245are marked with
246.Sq \&-\ \& ;
247those added to
248.Ar file2
249are marked
250.Sq +\ \& .
251Lines which are changed from one file to the other are marked in
252both files with
253.Sq !\ \& .
254Changes which lie within 3 lines of each other are grouped together on
255output.
256.It Fl D Ar string Fl -ifdef Ar string
257Creates a merged version of
258.Ar file1
259and
260.Ar file2
261on the standard output, with C preprocessor controls included so that
262a compilation of the result without defining
263.Ar string
264is equivalent to compiling
265.Ar file1 ,
266while defining
267.Ar string
268will yield
269.Ar file2 .
270.It Fl e -ed
271Produces output in a form suitable as input for the editor utility,
272.Xr ed 1 ,
273which can then be used to convert file1 into file2.
274.Pp
275Extra commands are added to the output when comparing directories with
276.Fl e ,
277so that the result is a
278.Xr sh 1
279script for converting text files which are common to the two directories
280from their state in
281.Ar dir1
282to their state in
283.Ar dir2 .
284Note that when comparing directories with
285.Fl e ,
286the resulting file may no longer be interpreted as an
287.Xr ed 1
288script.
289Output is added to indicate which file each set of
290.Xr ed 1
291commands applies to.
292These hunks can be manually extracted to produce an
293.Xr ed 1
294script, which can also be applied with
295.Xr patch 1 .
296.It Fl f -forward-ed
297Identical output to that of the
298.Fl e
299flag, but in reverse order.
300It cannot be digested by
301.Xr ed 1 .
302.It Fl -help
303This option prints a summary to stdout and exits with status 0.
304.It Fl n
305Produces a script similar to that of
306.Fl e ,
307but in the opposite order and with a count of changed lines on each
308insert or delete command.
309This is the form used by rcsdiff.
310.It Fl q -brief
311Just print a line when the files differ.
312Does not output a list of changes.
313.It Fl U Ar number Fl -unified Ar number
314Like
315.Fl u
316but produces a diff with
317.Ar number
318lines of context.
319.It Fl u
320Produces a
321.Em unified
322diff with 3 lines of context.
323A unified diff is similar to the context diff produced by the
324.Fl c
325option.
326However, unlike with
327.Fl c ,
328all lines to be changed (added and/or removed) are present in
329a single section.
330.It Fl -version
331This option prints a version string to stdout and exits with status 0.
332.It Fl y Fl -side-by-side
333Output in two columns with a marker between them.
334The marker can be one
335of the following:
336.Pp
337.Bl -tag -width Ds -offset indent -compact
338.It space
339Corresponding lines are identical.
340.It '|'
341Corresponding lines are different.
342.It '<'
343Files differ and only the first file contains the line.
344.It '>'
345Files differ and only the second file contains the line.
346.El
347.El
348.Pp
349Comparison options:
350.Bl -tag -width Ds
351.It Fl A Ar algo, Fl -algorithm Ar algo
352Configure the algorithm used when comparing files.
353.Nm
354supports 3 algorithms:
355.Pp
356.Bl -tag -width Ds -compact
357.It Cm myers
358The Myers diff algorithm finds the shortest edit which transforms one
359input into the other.
360It generally runs in O(N+D\(S2) time, requiring O(N) space, where N is
361the sum of the lengths of the inputs and D is the length of the
362difference between them, with a theoretical O(N\(pcD) worst case.
363If it encounters worst-case input, the implementation used by
364.Nm
365falls back to a less optimal but faster algorithm.
366.It Cm patience
367The Patience variant of the Myers algorithm attempts to create more
368aesthetically pleasing diff output by logically grouping lines.
369.It Cm stone
370The Stone algorithm (commonly known as Hunt-McIlroy or Hunt-Szymanski)
371looks for the longest common subsequence between compared files.
372Stone encounters worst case performance when there are long common
373subsequences.
374In large files this can lead to a significant performance impact.
375The Stone algorithm is maintained for compatibility.
376.El
377.Pp
378The
379.Nm
380utility defaults to the Myers algorithm, but will fall back to the
381Stone algorithm if the input or output options are not supported by
382the Myers implementation.
383.It Fl a -text
384Treat all files as ASCII text.
385Normally
386.Nm
387will simply print
388.Dq Binary files ... differ
389if files contain binary characters.
390Use of this option forces
391.Nm
392to produce a diff.
393.It Fl B Fl -ignore-blank-lines
394Causes chunks that include only blank lines to be ignored.
395.It Fl b -ignore-space-change
396Causes trailing blanks (spaces and tabs) to be ignored, and other
397strings of blanks to compare equal.
398.It Fl -color= Ns Oo Ar when Oc
399Color the additions green, and removals red, or the value in the
400.Ev DIFFCOLORS
401environment variable.
402The possible values of
403.Ar when
404are
405.Dq Cm never ,
406.Dq Cm always
407and
408.Dq Cm auto .
409.Cm auto
410will use color if the output is a tty and the
411.Ev COLORTERM
412environment variable is set to a non-empty string.
413.It Fl d -minimal
414Try very hard to produce a diff as small as possible.
415This may consume a lot of processing power and memory when processing
416large files with many changes.
417.It Fl F Ar pattern, Fl -show-function-line Ar pattern
418Like
419.Fl p,
420but display the last line that matches provided pattern.
421.It Fl I Ar pattern Fl -ignore-matching-lines Ar pattern
422Ignores changes, insertions, and deletions whose lines match the
423extended regular expression
424.Ar pattern .
425Multiple
426.Fl I
427patterns may be specified.
428All lines in the change must match some pattern for the change to be
429ignored.
430See
431.Xr re_format 7
432for more information on regular expression patterns.
433.It Fl i -ignore-case
434Ignores the case of letters.
435E.g.,
436.Dq A
437will compare equal to
438.Dq a .
439.It Fl l -paginate
440Pass the output through
441.Xr pr 1
442to paginate it.
443.It Fl L Ar label Fl -label Ar label
444Print
445.Ar label
446instead of the first (and second, if this option is specified twice)
447file name and time in the context or unified diff header.
448.It Fl p -show-c-function
449With unified and context diffs, show with each change
450the first 40 characters of the last line before the context beginning
451with a letter, an underscore or a dollar sign.
452For C and Objective-C source code following standard layout conventions, this
453will show the prototype of the function the change applies to.
454.It Fl T -initial-tab
455Print a tab rather than a space before the rest of the line for the
456normal, context or unified output formats.
457This makes the alignment of tabs in the line consistent.
458.It Fl t -expand-tabs
459Will expand tabs in output lines.
460Normal or
461.Fl c
462output adds character(s) to the front of each line which may screw up
463the indentation of the original source lines and make the output listing
464difficult to interpret.
465This option will preserve the original source's indentation.
466.It Fl w -ignore-all-blanks
467Is similar to
468.Fl b -ignore-space-change
469but causes whitespace (blanks and tabs) to be totally ignored.
470E.g.,
471.Dq if (\ \&a == b \&)
472will compare equal to
473.Dq if(a==b) .
474.It Fl W Ar number Fl -width Ar number
475Output at most
476.Ar number
477columns when using side by side format.
478The default value is 130.
479Note that unless
480.It Fl t
481was specified,
482.Nm
483will always align the second column to a tab stop, so values of
484.Fl -width
485smaller than approximately five times the value of
486.Fl -tabsize
487may yield surprising results.
488.It Fl -changed-group-format Ar GFMT
489Format input groups in the provided
490.Pp
491the format is a string with special keywords:
492.Bl -tag -width %<
493.It %<
494lines from FILE1
495.It %<
496lines from FILE2
497.El
498.It Fl -ignore-file-name-case
499ignore case when comparing file names
500.It Fl -no-ignore-file-name-case
501do not ignore case when comparing file names (default)
502.It Fl -normal
503default diff output
504.It Fl -speed-large-files
505stub option for compatibility with GNU diff
506.It Fl -strip-trailing-cr
507strip carriage return on input files
508.It Fl -suppress-common-lines
509Do not output common lines when using the side by side format
510.It Fl -tabsize Ar number
511Number of spaces representing a tab (default 8)
512.El
513.Pp
514Directory comparison options:
515.Bl -tag -width Ds
516.It Fl N -new-file
517If a file is found in only one directory, act as if it was found in the
518other directory too but was of zero size.
519.It Fl P -unidirectional-new-file
520If a file is found only in
521.Ar dir2 ,
522act as if it was found in
523.Ar dir1
524too but was of zero size.
525.It Fl r -recursive
526Causes application of
527.Nm
528recursively to common subdirectories encountered.
529.It Fl S Ar name Fl -starting-file Ar name
530Re-starts a directory
531.Nm
532in the middle, beginning with file
533.Ar name .
534.It Fl s -report-identical-files
535Causes
536.Nm
537to report files which are the same, which are otherwise not mentioned.
538.It Fl X Ar file Fl -exclude-from Ar file
539Exclude files and subdirectories from comparison whose basenames match
540lines in
541.Ar file .
542Multiple
543.Fl X
544options may be specified.
545.It Fl x Ar pattern Fl -exclude Ar pattern
546Exclude files and subdirectories from comparison whose basenames match
547.Ar pattern .
548Patterns are matched using shell-style globbing via
549.Xr fnmatch 3 .
550Multiple
551.Fl x
552options may be specified.
553.El
554.Pp
555If both arguments are directories,
556.Nm
557sorts the contents of the directories by name, and then runs the
558regular file
559.Nm
560algorithm, producing a change list,
561on text files which are different.
562Binary files which differ,
563common subdirectories, and files which appear in only one directory
564are described as such.
565In directory mode only regular files and directories are compared.
566If a non-regular file such as a device special file or FIFO is encountered,
567a diagnostic message is printed.
568.Pp
569If only one of
570.Ar file1
571and
572.Ar file2
573is a directory,
574.Nm
575is applied to the non-directory file and the file contained in
576the directory file with a filename that is the same as the
577last component of the non-directory file.
578.Pp
579If either
580.Ar file1
581or
582.Ar file2
583is
584.Sq - ,
585the standard input is
586used in its place.
587.Ss Output Style
588The default (without
589.Fl e ,
590.Fl c ,
591or
592.Fl n -rcs
593.\" -C
594options)
595output contains lines of these forms, where
596.Va XX , YY , ZZ , QQ
597are line numbers respective of file order.
598.Pp
599.Bl -tag -width "XX,YYcZZ,QQ" -compact
600.It Li XX Ns Ic a Ns Li YY
601At (the end of) line
602.Va XX
603of
604.Ar file1 ,
605append the contents
606of line
607.Va YY
608of
609.Ar file2
610to make them equal.
611.It Li XX Ns Ic a Ns Li YY,ZZ
612Same as above, but append the range of lines,
613.Va YY
614through
615.Va ZZ
616of
617.Ar file2
618to line
619.Va XX
620of file1.
621.It Li XX Ns Ic d Ns Li YY
622At line
623.Va XX
624delete
625the line.
626The value
627.Va YY
628tells to which line the change would bring
629.Ar file1
630in line with
631.Ar file2 .
632.It Li XX,YY Ns Ic d Ns Li ZZ
633Delete the range of lines
634.Va XX
635through
636.Va YY
637in
638.Ar file1 .
639.It Li XX Ns Ic c Ns Li YY
640Change the line
641.Va XX
642in
643.Ar file1
644to the line
645.Va YY
646in
647.Ar file2 .
648.It Li XX,YY Ns Ic c Ns Li ZZ
649Replace the range of specified lines with the line
650.Va ZZ .
651.It Li XX,YY Ns Ic c Ns Li ZZ,QQ
652Replace the range
653.Va XX , Ns Va YY
654from
655.Ar file1
656with the range
657.Va ZZ , Ns Va QQ
658from
659.Ar file2 .
660.El
661.Pp
662These lines resemble
663.Xr ed 1
664subcommands to convert
665.Ar file1
666into
667.Ar file2 .
668The line numbers before the action letters pertain to
669.Ar file1 ;
670those after pertain to
671.Ar file2 .
672Thus, by exchanging
673.Ic a
674for
675.Ic d
676and reading the line in reverse order, one can also
677determine how to convert
678.Ar file2
679into
680.Ar file1 .
681As in
682.Xr ed 1 ,
683identical
684pairs (where num1 = num2) are abbreviated as a single
685number.
686.Sh ENVIRONMENT
687.Bl -tag -width DIFFCOLORS
688.It Ev DIFFCOLORS
689The value of this variable is the form
690.Ar add Ns : Ns Ar rm ,
691where
692.Ar add
693is the ASCII escape sequence for additions and
694.Ar rm
695is the ASCII escape sequence for deletions.
696If this is unset,
697.Nm
698uses green for additions and red for removals.
699.El
700.Sh FILES
701.Bl -tag -width /tmp/diff.XXXXXXXX -compact
702.It Pa /tmp/diff.XXXXXXXX
703Temporary file used when comparing a device or the standard input.
704Note that the temporary file is unlinked as soon as it is created
705so it will not show up in a directory listing.
706.El
707.Sh EXIT STATUS
708The
709.Nm
710utility exits with one of the following values:
711.Pp
712.Bl -tag -width Ds -offset indent -compact
713.It 0
714No differences were found.
715.It 1
716Differences were found.
717.It >1
718An error occurred.
719.El
720.Pp
721The
722.Fl -help
723and
724.Fl -version
725options exit with a status of 0.
726.Sh EXAMPLES
727Compare
728.Pa old_dir
729and
730.Pa new_dir
731recursively generating an unified diff and treating files found only in one
732of those directories as new files:
733.Bd -literal -offset indent
734$ diff -ruN /path/to/old_dir /path/to/new_dir
735.Ed
736.Pp
737Same as above but excluding files matching the expressions
738.Dq *.h
739and
740.Dq *.c :
741.Bd -literal -offset indent
742$ diff -ruN -x '*.h' -x '*.c' /path/to/old_dir /path/to/new_dir
743.Ed
744.Pp
745Show a single line indicating if the files differ:
746.Bd -literal -offset indent
747$ diff -q /boot/loader.conf /boot/defaults/loader.conf
748Files /boot/loader.conf and /boot/defaults/loader.conf differ
749.Ed
750.Pp
751Assuming a file named
752.Pa example.txt
753with the following contents:
754.Bd -literal -offset indent
755FreeBSD is an operating system
756Linux is a kernel
757OpenBSD is an operating system
758.Ed
759.Pp
760Compare stdin with
761.Pa example.txt
762excluding from the comparison those lines containing either
763.Qq Linux
764or
765.Qq Open :
766.Bd -literal -offset indent
767$ echo "FreeBSD is an operating system" | diff -q -I 'Linux|Open' example.txt -
768.Ed
769.Sh SEE ALSO
770.Xr cmp 1 ,
771.Xr comm 1 ,
772.Xr diff3 1 ,
773.Xr ed 1 ,
774.Xr patch 1 ,
775.Xr pr 1 ,
776.Xr sdiff 1
777.Rs
778.%A James W. Hunt
779.%A M. Douglas McIlroy
780.%T "An Algorithm for Differential File Comparison"
781.%J Computing Science Technical Report
782.%Q Bell Laboratories 41
783.%D June 1976
784.Re
785.Sh STANDARDS
786The
787.Nm
788utility is compliant with the
789.St -p1003.1-2008
790specification.
791.Pp
792The flags
793.Op Fl AaDdIiLlNnPpqSsTtwXxy
794are extensions to that specification.
795.Sh HISTORY
796A
797.Nm
798command appeared in
799.At v6 .
800The
801.Nm
802implementation used in
803.Fx
804was GNU diff until
805.Fx 11.4 .
806This was replaced in
807.Fx 12.0
808by a BSD-licensed implementation written by
809.An Todd Miller .
810Some GNUisms were lost in the process.
811.Pp
812libdiff was imported from the Game of Trees version control system and default
813algorithm was changed to Myers for FreeBSD 15.
814