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