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