13bbe3f67SBaptiste Daroussin.\" $OpenBSD: diff.1,v 1.47 2015/11/24 19:35:41 jmc Exp $ 23bbe3f67SBaptiste Daroussin.\" 33bbe3f67SBaptiste Daroussin.\" Copyright (c) 1980, 1990, 1993 43bbe3f67SBaptiste Daroussin.\" The Regents of the University of California. All rights reserved. 53bbe3f67SBaptiste Daroussin.\" 63bbe3f67SBaptiste Daroussin.\" Redistribution and use in source and binary forms, with or without 73bbe3f67SBaptiste Daroussin.\" modification, are permitted provided that the following conditions 83bbe3f67SBaptiste Daroussin.\" are met: 93bbe3f67SBaptiste Daroussin.\" 1. Redistributions of source code must retain the above copyright 103bbe3f67SBaptiste Daroussin.\" notice, this list of conditions and the following disclaimer. 113bbe3f67SBaptiste Daroussin.\" 2. Redistributions in binary form must reproduce the above copyright 123bbe3f67SBaptiste Daroussin.\" notice, this list of conditions and the following disclaimer in the 133bbe3f67SBaptiste Daroussin.\" documentation and/or other materials provided with the distribution. 143bbe3f67SBaptiste Daroussin.\" 3. Neither the name of the University nor the names of its contributors 153bbe3f67SBaptiste Daroussin.\" may be used to endorse or promote products derived from this software 163bbe3f67SBaptiste Daroussin.\" without specific prior written permission. 173bbe3f67SBaptiste Daroussin.\" 183bbe3f67SBaptiste Daroussin.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 193bbe3f67SBaptiste Daroussin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 203bbe3f67SBaptiste Daroussin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 213bbe3f67SBaptiste Daroussin.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 223bbe3f67SBaptiste Daroussin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 233bbe3f67SBaptiste Daroussin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 243bbe3f67SBaptiste Daroussin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 253bbe3f67SBaptiste Daroussin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 263bbe3f67SBaptiste Daroussin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 273bbe3f67SBaptiste Daroussin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 283bbe3f67SBaptiste Daroussin.\" SUCH DAMAGE. 293bbe3f67SBaptiste Daroussin.\" 30*ab830de9SDag-Erling Smørgrav.Dd July 26, 2024 313bbe3f67SBaptiste Daroussin.Dt DIFF 1 323bbe3f67SBaptiste Daroussin.Os 333bbe3f67SBaptiste Daroussin.Sh NAME 343bbe3f67SBaptiste Daroussin.Nm diff 353bbe3f67SBaptiste Daroussin.Nd differential file and directory comparator 363bbe3f67SBaptiste Daroussin.Sh SYNOPSIS 373bbe3f67SBaptiste Daroussin.Nm diff 38e68edb8cSKyle Evans.Op Fl aBbdipTtw 393bbe3f67SBaptiste Daroussin.Oo 403bbe3f67SBaptiste Daroussin.Fl c | e | f | 4164793e74SBaptiste Daroussin.Fl n | q | u | y 423bbe3f67SBaptiste Daroussin.Oc 43d9a9f23dSDag-Erling Smørgrav.Op Fl A Ar algo | Fl -algorithm Ar algo 447dacb9e7SEnji Cooper.Op Fl -brief 45f38702e5SCameron Katri.Op Fl -color Ns = Ns Ar when 46fddcb7b8SBaptiste Daroussin.Op Fl -changed-group-format Ar GFMT 477dacb9e7SEnji Cooper.Op Fl -ed 487dacb9e7SEnji Cooper.Op Fl -expand-tabs 497dacb9e7SEnji Cooper.Op Fl -forward-ed 507dacb9e7SEnji Cooper.Op Fl -ignore-all-space 513bbe3f67SBaptiste Daroussin.Op Fl -ignore-case 527dacb9e7SEnji Cooper.Op Fl -ignore-space-change 537dacb9e7SEnji Cooper.Op Fl -initial-tab 547dacb9e7SEnji Cooper.Op Fl -minimal 554ce4a0feSDag-Erling Smørgrav.Op Fl -no-dereference 5678b83a1eSEnji Cooper.Op Fl -no-ignore-file-name-case 573bbe3f67SBaptiste Daroussin.Op Fl -normal 587dacb9e7SEnji Cooper.Op Fl -rcs 597dacb9e7SEnji Cooper.Op Fl -show-c-function 607dacb9e7SEnji Cooper.Op Fl -starting-file 61a077708dSBaptiste Daroussin.Op Fl -speed-large-files 623bbe3f67SBaptiste Daroussin.Op Fl -strip-trailing-cr 6343fbd654SKyle Evans.Op Fl -tabsize Ar number 647dacb9e7SEnji Cooper.Op Fl -text 657dacb9e7SEnji Cooper.Op Fl -unified 667dacb9e7SEnji Cooper.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern 67e51aabf8SPiotr Pawel Stefaniak.Op Fl F Ar pattern | Fl -show-function-line Ar pattern 687dacb9e7SEnji Cooper.Op Fl L Ar label | Fl -label Ar label 693bbe3f67SBaptiste Daroussin.Ar file1 file2 703bbe3f67SBaptiste Daroussin.Nm diff 71e68edb8cSKyle Evans.Op Fl aBbdilpTtw 72d9a9f23dSDag-Erling Smørgrav.Op Fl A Ar algo | Fl -algorithm Ar algo 737dacb9e7SEnji Cooper.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern 74e51aabf8SPiotr Pawel Stefaniak.Op Fl F Ar pattern | Fl -show-function-line Ar pattern 757dacb9e7SEnji Cooper.Op Fl L Ar label | Fl -label Ar label 767dacb9e7SEnji Cooper.Op Fl -brief 77f38702e5SCameron Katri.Op Fl -color Ns = Ns Ar when 78fddcb7b8SBaptiste Daroussin.Op Fl -changed-group-format Ar GFMT 797dacb9e7SEnji Cooper.Op Fl -ed 807dacb9e7SEnji Cooper.Op Fl -expand-tabs 817dacb9e7SEnji Cooper.Op Fl -forward-ed 827dacb9e7SEnji Cooper.Op Fl -ignore-all-space 833bbe3f67SBaptiste Daroussin.Op Fl -ignore-case 847dacb9e7SEnji Cooper.Op Fl -ignore-space-change 857dacb9e7SEnji Cooper.Op Fl -initial-tab 867dacb9e7SEnji Cooper.Op Fl -minimal 874ce4a0feSDag-Erling Smørgrav.Op Fl -no-dereference 8878b83a1eSEnji Cooper.Op Fl -no-ignore-file-name-case 893bbe3f67SBaptiste Daroussin.Op Fl -normal 907dacb9e7SEnji Cooper.Op Fl -paginate 917dacb9e7SEnji Cooper.Op Fl -rcs 927dacb9e7SEnji Cooper.Op Fl -show-c-function 93a077708dSBaptiste Daroussin.Op Fl -speed-large-files 947dacb9e7SEnji Cooper.Op Fl -starting-file 953bbe3f67SBaptiste Daroussin.Op Fl -strip-trailing-cr 9643fbd654SKyle Evans.Op Fl -tabsize Ar number 977dacb9e7SEnji Cooper.Op Fl -text 987dacb9e7SEnji Cooper.Fl C Ar number | -context Ar number 993bbe3f67SBaptiste Daroussin.Ar file1 file2 1003bbe3f67SBaptiste Daroussin.Nm diff 101e68edb8cSKyle Evans.Op Fl aBbdiltw 102d9a9f23dSDag-Erling Smørgrav.Op Fl A Ar algo | Fl -algorithm Ar algo 1037dacb9e7SEnji Cooper.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern 1047dacb9e7SEnji Cooper.Op Fl -brief 105f38702e5SCameron Katri.Op Fl -color Ns = Ns Ar when 106fddcb7b8SBaptiste Daroussin.Op Fl -changed-group-format Ar GFMT 1077dacb9e7SEnji Cooper.Op Fl -ed 1087dacb9e7SEnji Cooper.Op Fl -expand-tabs 1097dacb9e7SEnji Cooper.Op Fl -forward-ed 1107dacb9e7SEnji Cooper.Op Fl -ignore-all-space 1113bbe3f67SBaptiste Daroussin.Op Fl -ignore-case 1127dacb9e7SEnji Cooper.Op Fl -ignore-space-change 1137dacb9e7SEnji Cooper.Op Fl -initial-tab 1147dacb9e7SEnji Cooper.Op Fl -minimal 1154ce4a0feSDag-Erling Smørgrav.Op Fl -no-dereference 11678b83a1eSEnji Cooper.Op Fl -no-ignore-file-name-case 1173bbe3f67SBaptiste Daroussin.Op Fl -normal 1187dacb9e7SEnji Cooper.Op Fl -paginate 1197dacb9e7SEnji Cooper.Op Fl -rcs 1207dacb9e7SEnji Cooper.Op Fl -show-c-function 121a077708dSBaptiste Daroussin.Op Fl -speed-large-files 1227dacb9e7SEnji Cooper.Op Fl -starting-file 1233bbe3f67SBaptiste Daroussin.Op Fl -strip-trailing-cr 12443fbd654SKyle Evans.Op Fl -tabsize Ar number 1257dacb9e7SEnji Cooper.Op Fl -text 1267dacb9e7SEnji Cooper.Fl D Ar string | Fl -ifdef Ar string 1273bbe3f67SBaptiste Daroussin.Ar file1 file2 1283bbe3f67SBaptiste Daroussin.Nm diff 129e68edb8cSKyle Evans.Op Fl aBbdilpTtw 130d9a9f23dSDag-Erling Smørgrav.Op Fl A Ar algo | Fl -algorithm Ar algo 1317dacb9e7SEnji Cooper.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern 132e51aabf8SPiotr Pawel Stefaniak.Op Fl F Ar pattern | Fl -show-function-line Ar pattern 1337dacb9e7SEnji Cooper.Op Fl L Ar label | Fl -label Ar label 1347dacb9e7SEnji Cooper.Op Fl -brief 135f38702e5SCameron Katri.Op Fl -color Ns = Ns Ar when 136fddcb7b8SBaptiste Daroussin.Op Fl -changed-group-format Ar GFMT 1377dacb9e7SEnji Cooper.Op Fl -ed 1387dacb9e7SEnji Cooper.Op Fl -expand-tabs 1397dacb9e7SEnji Cooper.Op Fl -forward-ed 1407dacb9e7SEnji Cooper.Op Fl -ignore-all-space 1413bbe3f67SBaptiste Daroussin.Op Fl -ignore-case 1427dacb9e7SEnji Cooper.Op Fl -ignore-space-change 1437dacb9e7SEnji Cooper.Op Fl -initial-tab 1447dacb9e7SEnji Cooper.Op Fl -minimal 1454ce4a0feSDag-Erling Smørgrav.Op Fl -no-dereference 14678b83a1eSEnji Cooper.Op Fl -no-ignore-file-name-case 1473bbe3f67SBaptiste Daroussin.Op Fl -normal 1487dacb9e7SEnji Cooper.Op Fl -paginate 1497dacb9e7SEnji Cooper.Op Fl -rcs 1507dacb9e7SEnji Cooper.Op Fl -show-c-function 151a077708dSBaptiste Daroussin.Op Fl -speed-large-files 1527dacb9e7SEnji Cooper.Op Fl -starting-file 1533bbe3f67SBaptiste Daroussin.Op Fl -strip-trailing-cr 15443fbd654SKyle Evans.Op Fl -tabsize Ar number 1557dacb9e7SEnji Cooper.Op Fl -text 1567dacb9e7SEnji Cooper.Fl U Ar number | Fl -unified Ar number 1573bbe3f67SBaptiste Daroussin.Ar file1 file2 1583bbe3f67SBaptiste Daroussin.Nm diff 159e68edb8cSKyle Evans.Op Fl aBbdilNPprsTtw 1603bbe3f67SBaptiste Daroussin.Oo 1613bbe3f67SBaptiste Daroussin.Fl c | e | f | 1623bbe3f67SBaptiste Daroussin.Fl n | q | u 1633bbe3f67SBaptiste Daroussin.Oc 164d9a9f23dSDag-Erling Smørgrav.Op Fl A Ar algo | Fl -algorithm Ar algo 1657dacb9e7SEnji Cooper.Op Fl -brief 166f38702e5SCameron Katri.Op Fl -color Ns = Ns Ar when 167fddcb7b8SBaptiste Daroussin.Op Fl -changed-group-format Ar GFMT 1687dacb9e7SEnji Cooper.Op Fl -context 1697dacb9e7SEnji Cooper.Op Fl -ed 1707dacb9e7SEnji Cooper.Op Fl -expand-tabs 1717dacb9e7SEnji Cooper.Op Fl -forward-ed 1727dacb9e7SEnji Cooper.Op Fl -ignore-all-space 1733bbe3f67SBaptiste Daroussin.Op Fl -ignore-case 1747dacb9e7SEnji Cooper.Op Fl -ignore-space-change 1757dacb9e7SEnji Cooper.Op Fl -initial-tab 1767dacb9e7SEnji Cooper.Op Fl -minimal 1777dacb9e7SEnji Cooper.Op Fl -new-file 1784ce4a0feSDag-Erling Smørgrav.Op Fl -no-dereference 17978b83a1eSEnji Cooper.Op Fl -no-ignore-file-name-case 1803bbe3f67SBaptiste Daroussin.Op Fl -normal 1817dacb9e7SEnji Cooper.Op Fl -paginate 1827dacb9e7SEnji Cooper.Op Fl -rcs 1837dacb9e7SEnji Cooper.Op Fl -recursive 1847dacb9e7SEnji Cooper.Op Fl -report-identical-files 1857dacb9e7SEnji Cooper.Op Fl -show-c-function 186a077708dSBaptiste Daroussin.Op Fl -speed-large-files 1879ba27624SEnji Cooper.Op Fl -strip-trailing-cr 18843fbd654SKyle Evans.Op Fl -tabsize Ar number 1897dacb9e7SEnji Cooper.Op Fl -text 1907dacb9e7SEnji Cooper.Op Fl -unidirectional-new-file 1917dacb9e7SEnji Cooper.Op Fl -unified 1927dacb9e7SEnji Cooper.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern 193e51aabf8SPiotr Pawel Stefaniak.Op Fl F Ar pattern | Fl -show-function-line Ar pattern 1943bbe3f67SBaptiste Daroussin.Bk -words 1957dacb9e7SEnji Cooper.Op Fl L Ar label | Fl -label Ar label 1967dacb9e7SEnji Cooper.Op Fl S Ar name | Fl -starting-file Ar name 1977dacb9e7SEnji Cooper.Op Fl X Ar file | Fl -exclude-from Ar file 1987dacb9e7SEnji Cooper.Op Fl x Ar pattern | Fl -exclude Ar pattern 1993bbe3f67SBaptiste Daroussin.Ek 2003bbe3f67SBaptiste Daroussin.Ar dir1 dir2 20164793e74SBaptiste Daroussin.Nm diff 20264793e74SBaptiste Daroussin.Op Fl aBbditwW 203f38702e5SCameron Katri.Op Fl -color Ns = Ns Ar when 204469635f6SMateusz Piotrowski.Op Fl -expand-tabs 205*ab830de9SDag-Erling Smørgrav.Op Fl -ignore-all-space 206469635f6SMateusz Piotrowski.Op Fl -ignore-blank-lines 207469635f6SMateusz Piotrowski.Op Fl -ignore-case 208469635f6SMateusz Piotrowski.Op Fl -minimal 2094ce4a0feSDag-Erling Smørgrav.Op Fl -no-dereference 210469635f6SMateusz Piotrowski.Op Fl -no-ignore-file-name-case 211469635f6SMateusz Piotrowski.Op Fl -strip-trailing-cr 212469635f6SMateusz Piotrowski.Op Fl -suppress-common-lines 21343fbd654SKyle Evans.Op Fl -tabsize Ar number 214469635f6SMateusz Piotrowski.Op Fl -text 215469635f6SMateusz Piotrowski.Op Fl -width 21664793e74SBaptiste Daroussin.Fl y | Fl -side-by-side 21764793e74SBaptiste Daroussin.Ar file1 file2 2188cf449dbSTom Jones.Nm diff 2198cf449dbSTom Jones.Op Fl -help 2208cf449dbSTom Jones.Op Fl -version 2213bbe3f67SBaptiste Daroussin.Sh DESCRIPTION 2223bbe3f67SBaptiste DaroussinThe 2233bbe3f67SBaptiste Daroussin.Nm 2243bbe3f67SBaptiste Daroussinutility compares the contents of 2253bbe3f67SBaptiste Daroussin.Ar file1 2263bbe3f67SBaptiste Daroussinand 2273bbe3f67SBaptiste Daroussin.Ar file2 2283bbe3f67SBaptiste Daroussinand writes to the standard output the list of changes necessary to 2293bbe3f67SBaptiste Daroussinconvert one file into the other. 2303bbe3f67SBaptiste DaroussinNo output is produced if the files are identical. 2313bbe3f67SBaptiste Daroussin.Pp 2323bbe3f67SBaptiste DaroussinOutput options (mutually exclusive): 2333bbe3f67SBaptiste Daroussin.Bl -tag -width Ds 234bcf91ad6SBaptiste Daroussin.It Fl C Ar number Fl -context Ar number 2353bbe3f67SBaptiste DaroussinLike 2363bbe3f67SBaptiste Daroussin.Fl c 2373bbe3f67SBaptiste Daroussinbut produces a diff with 2383bbe3f67SBaptiste Daroussin.Ar number 2393bbe3f67SBaptiste Daroussinlines of context. 2403bbe3f67SBaptiste Daroussin.It Fl c 2413bbe3f67SBaptiste DaroussinProduces a diff with 3 lines of context. 2423bbe3f67SBaptiste DaroussinWith 2433bbe3f67SBaptiste Daroussin.Fl c 2443bbe3f67SBaptiste Daroussinthe output format is modified slightly: 2453bbe3f67SBaptiste Daroussinthe output begins with identification of the files involved and 2463bbe3f67SBaptiste Daroussintheir creation dates and then each change is separated 2473bbe3f67SBaptiste Daroussinby a line with fifteen 2483bbe3f67SBaptiste Daroussin.Li * Ns 's . 2493bbe3f67SBaptiste DaroussinThe lines removed from 2503bbe3f67SBaptiste Daroussin.Ar file1 2513bbe3f67SBaptiste Daroussinare marked with 2523bbe3f67SBaptiste Daroussin.Sq \&-\ \& ; 2533bbe3f67SBaptiste Daroussinthose added to 2543bbe3f67SBaptiste Daroussin.Ar file2 2553bbe3f67SBaptiste Daroussinare marked 25679208b10SBaptiste Daroussin.Sq +\ \& . 2573bbe3f67SBaptiste DaroussinLines which are changed from one file to the other are marked in 2583bbe3f67SBaptiste Daroussinboth files with 2593bbe3f67SBaptiste Daroussin.Sq !\ \& . 2603bbe3f67SBaptiste DaroussinChanges which lie within 3 lines of each other are grouped together on 2613bbe3f67SBaptiste Daroussinoutput. 262bcf91ad6SBaptiste Daroussin.It Fl D Ar string Fl -ifdef Ar string 2633bbe3f67SBaptiste DaroussinCreates a merged version of 2643bbe3f67SBaptiste Daroussin.Ar file1 2653bbe3f67SBaptiste Daroussinand 2663bbe3f67SBaptiste Daroussin.Ar file2 2673bbe3f67SBaptiste Daroussinon the standard output, with C preprocessor controls included so that 2683bbe3f67SBaptiste Daroussina compilation of the result without defining 2693bbe3f67SBaptiste Daroussin.Ar string 2703bbe3f67SBaptiste Daroussinis equivalent to compiling 2713bbe3f67SBaptiste Daroussin.Ar file1 , 2723bbe3f67SBaptiste Daroussinwhile defining 2733bbe3f67SBaptiste Daroussin.Ar string 2743bbe3f67SBaptiste Daroussinwill yield 2753bbe3f67SBaptiste Daroussin.Ar file2 . 276bcf91ad6SBaptiste Daroussin.It Fl e -ed 2773bbe3f67SBaptiste DaroussinProduces output in a form suitable as input for the editor utility, 2783bbe3f67SBaptiste Daroussin.Xr ed 1 , 2793bbe3f67SBaptiste Daroussinwhich can then be used to convert file1 into file2. 2803bbe3f67SBaptiste Daroussin.Pp 2813bbe3f67SBaptiste DaroussinExtra commands are added to the output when comparing directories with 2823bbe3f67SBaptiste Daroussin.Fl e , 2833bbe3f67SBaptiste Daroussinso that the result is a 2843bbe3f67SBaptiste Daroussin.Xr sh 1 2853bbe3f67SBaptiste Daroussinscript for converting text files which are common to the two directories 2863bbe3f67SBaptiste Daroussinfrom their state in 2873bbe3f67SBaptiste Daroussin.Ar dir1 2883bbe3f67SBaptiste Daroussinto their state in 2893bbe3f67SBaptiste Daroussin.Ar dir2 . 290d9a9f23dSDag-Erling SmørgravNote that when comparing directories with 291d9a9f23dSDag-Erling Smørgrav.Fl e , 292d9a9f23dSDag-Erling Smørgravthe resulting file may no longer be interpreted as an 293d9a9f23dSDag-Erling Smørgrav.Xr ed 1 294d9a9f23dSDag-Erling Smørgravscript. 295d9a9f23dSDag-Erling SmørgravOutput is added to indicate which file each set of 296d9a9f23dSDag-Erling Smørgrav.Xr ed 1 297d9a9f23dSDag-Erling Smørgravcommands applies to. 298d9a9f23dSDag-Erling SmørgravThese hunks can be manually extracted to produce an 299d9a9f23dSDag-Erling Smørgrav.Xr ed 1 300d9a9f23dSDag-Erling Smørgravscript, which can also be applied with 301d9a9f23dSDag-Erling Smørgrav.Xr patch 1 . 302bcf91ad6SBaptiste Daroussin.It Fl f -forward-ed 3033bbe3f67SBaptiste DaroussinIdentical output to that of the 3043bbe3f67SBaptiste Daroussin.Fl e 3053bbe3f67SBaptiste Daroussinflag, but in reverse order. 3063bbe3f67SBaptiste DaroussinIt cannot be digested by 3073bbe3f67SBaptiste Daroussin.Xr ed 1 . 3088cf449dbSTom Jones.It Fl -help 3098cf449dbSTom JonesThis option prints a summary to stdout and exits with status 0. 3103bbe3f67SBaptiste Daroussin.It Fl n 3113bbe3f67SBaptiste DaroussinProduces a script similar to that of 3123bbe3f67SBaptiste Daroussin.Fl e , 3133bbe3f67SBaptiste Daroussinbut in the opposite order and with a count of changed lines on each 3143bbe3f67SBaptiste Daroussininsert or delete command. 315204fa3b0SFernando ApesteguíaThis is the form used by rcsdiff. 316bcf91ad6SBaptiste Daroussin.It Fl q -brief 3173bbe3f67SBaptiste DaroussinJust print a line when the files differ. 3183bbe3f67SBaptiste DaroussinDoes not output a list of changes. 319bcf91ad6SBaptiste Daroussin.It Fl U Ar number Fl -unified Ar number 3203bbe3f67SBaptiste DaroussinLike 3213bbe3f67SBaptiste Daroussin.Fl u 3223bbe3f67SBaptiste Daroussinbut produces a diff with 3233bbe3f67SBaptiste Daroussin.Ar number 3243bbe3f67SBaptiste Daroussinlines of context. 3253bbe3f67SBaptiste Daroussin.It Fl u 3263bbe3f67SBaptiste DaroussinProduces a 3273bbe3f67SBaptiste Daroussin.Em unified 3283bbe3f67SBaptiste Daroussindiff with 3 lines of context. 3293bbe3f67SBaptiste DaroussinA unified diff is similar to the context diff produced by the 3303bbe3f67SBaptiste Daroussin.Fl c 3313bbe3f67SBaptiste Daroussinoption. 3323bbe3f67SBaptiste DaroussinHowever, unlike with 3333bbe3f67SBaptiste Daroussin.Fl c , 3343bbe3f67SBaptiste Daroussinall lines to be changed (added and/or removed) are present in 3353bbe3f67SBaptiste Daroussina single section. 3368cf449dbSTom Jones.It Fl -version 3378cf449dbSTom JonesThis option prints a version string to stdout and exits with status 0. 33864793e74SBaptiste Daroussin.It Fl y Fl -side-by-side 33979208b10SBaptiste DaroussinOutput in two columns with a marker between them. 34079208b10SBaptiste DaroussinThe marker can be one 34164793e74SBaptiste Daroussinof the following: 34264793e74SBaptiste Daroussin.Pp 34364793e74SBaptiste Daroussin.Bl -tag -width Ds -offset indent -compact 34464793e74SBaptiste Daroussin.It space 34564793e74SBaptiste DaroussinCorresponding lines are identical. 34664793e74SBaptiste Daroussin.It '|' 34764793e74SBaptiste DaroussinCorresponding lines are different. 34864793e74SBaptiste Daroussin.It '<' 34964793e74SBaptiste DaroussinFiles differ and only the first file contains the line. 35064793e74SBaptiste Daroussin.It '>' 35164793e74SBaptiste DaroussinFiles differ and only the second file contains the line. 35264793e74SBaptiste Daroussin.El 3533bbe3f67SBaptiste Daroussin.El 3543bbe3f67SBaptiste Daroussin.Pp 3553bbe3f67SBaptiste DaroussinComparison options: 3563bbe3f67SBaptiste Daroussin.Bl -tag -width Ds 357d9a9f23dSDag-Erling Smørgrav.It Fl A Ar algo, Fl -algorithm Ar algo 358d9a9f23dSDag-Erling SmørgravConfigure the algorithm used when comparing files. 359d9a9f23dSDag-Erling Smørgrav.Nm 360d9a9f23dSDag-Erling Smørgravsupports 3 algorithms: 361d9a9f23dSDag-Erling Smørgrav.Pp 362d9a9f23dSDag-Erling Smørgrav.Bl -tag -width Ds -compact 363d9a9f23dSDag-Erling Smørgrav.It Cm myers 364d9a9f23dSDag-Erling SmørgravThe Myers diff algorithm finds the shortest edit which transforms one 365d9a9f23dSDag-Erling Smørgravinput into the other. 366d9a9f23dSDag-Erling SmørgravIt generally runs in O(N+D\(S2) time, requiring O(N) space, where N is 367d9a9f23dSDag-Erling Smørgravthe sum of the lengths of the inputs and D is the length of the 368d9a9f23dSDag-Erling Smørgravdifference between them, with a theoretical O(N\(pcD) worst case. 369d9a9f23dSDag-Erling SmørgravIf it encounters worst-case input, the implementation used by 370d9a9f23dSDag-Erling Smørgrav.Nm 371d9a9f23dSDag-Erling Smørgravfalls back to a less optimal but faster algorithm. 372d9a9f23dSDag-Erling Smørgrav.It Cm patience 373d9a9f23dSDag-Erling SmørgravThe Patience variant of the Myers algorithm attempts to create more 374d9a9f23dSDag-Erling Smørgravaesthetically pleasing diff output by logically grouping lines. 375d9a9f23dSDag-Erling Smørgrav.It Cm stone 376d9a9f23dSDag-Erling SmørgravThe Stone algorithm (commonly known as Hunt-McIlroy or Hunt-Szymanski) 377d9a9f23dSDag-Erling Smørgravlooks for the longest common subsequence between compared files. 378d9a9f23dSDag-Erling SmørgravStone encounters worst case performance when there are long common 379d9a9f23dSDag-Erling Smørgravsubsequences. 380d9a9f23dSDag-Erling SmørgravIn large files this can lead to a significant performance impact. 381d9a9f23dSDag-Erling SmørgravThe Stone algorithm is maintained for compatibility. 382d9a9f23dSDag-Erling Smørgrav.El 383d9a9f23dSDag-Erling Smørgrav.Pp 384d9a9f23dSDag-Erling SmørgravThe 385d9a9f23dSDag-Erling Smørgrav.Nm 386d9a9f23dSDag-Erling Smørgravutility defaults to the Myers algorithm, but will fall back to the 387d9a9f23dSDag-Erling SmørgravStone algorithm if the input or output options are not supported by 388d9a9f23dSDag-Erling Smørgravthe Myers implementation. 389bcf91ad6SBaptiste Daroussin.It Fl a -text 39079208b10SBaptiste DaroussinTreat all files as ASCII text. 3913bbe3f67SBaptiste DaroussinNormally 3923bbe3f67SBaptiste Daroussin.Nm 3933bbe3f67SBaptiste Daroussinwill simply print 3943bbe3f67SBaptiste Daroussin.Dq Binary files ... differ 3953bbe3f67SBaptiste Daroussinif files contain binary characters. 3963bbe3f67SBaptiste DaroussinUse of this option forces 3973bbe3f67SBaptiste Daroussin.Nm 3983bbe3f67SBaptiste Daroussinto produce a diff. 399e68edb8cSKyle Evans.It Fl B Fl -ignore-blank-lines 400e68edb8cSKyle EvansCauses chunks that include only blank lines to be ignored. 4018ccef193SBaptiste Daroussin.It Fl b -ignore-space-change 4023bbe3f67SBaptiste DaroussinCauses trailing blanks (spaces and tabs) to be ignored, and other 4033bbe3f67SBaptiste Daroussinstrings of blanks to compare equal. 404f38702e5SCameron Katri.It Fl -color= Ns Oo Ar when Oc 405f38702e5SCameron KatriColor the additions green, and removals red, or the value in the 406f38702e5SCameron Katri.Ev DIFFCOLORS 407f38702e5SCameron Katrienvironment variable. 408f38702e5SCameron KatriThe possible values of 409f38702e5SCameron Katri.Ar when 410f38702e5SCameron Katriare 411f38702e5SCameron Katri.Dq Cm never , 412f38702e5SCameron Katri.Dq Cm always 413f38702e5SCameron Katriand 414f38702e5SCameron Katri.Dq Cm auto . 415f38702e5SCameron Katri.Cm auto 416f38702e5SCameron Katriwill use color if the output is a tty and the 417f38702e5SCameron Katri.Ev COLORTERM 418f38702e5SCameron Katrienvironment variable is set to a non-empty string. 419bcf91ad6SBaptiste Daroussin.It Fl d -minimal 4203bbe3f67SBaptiste DaroussinTry very hard to produce a diff as small as possible. 4213bbe3f67SBaptiste DaroussinThis may consume a lot of processing power and memory when processing 4223bbe3f67SBaptiste Daroussinlarge files with many changes. 423e51aabf8SPiotr Pawel Stefaniak.It Fl F Ar pattern, Fl -show-function-line Ar pattern 424e51aabf8SPiotr Pawel StefaniakLike 425e51aabf8SPiotr Pawel Stefaniak.Fl p, 426e51aabf8SPiotr Pawel Stefaniakbut display the last line that matches provided pattern. 427bcf91ad6SBaptiste Daroussin.It Fl I Ar pattern Fl -ignore-matching-lines Ar pattern 4283bbe3f67SBaptiste DaroussinIgnores changes, insertions, and deletions whose lines match the 4293bbe3f67SBaptiste Daroussinextended regular expression 4303bbe3f67SBaptiste Daroussin.Ar pattern . 4313bbe3f67SBaptiste DaroussinMultiple 4323bbe3f67SBaptiste Daroussin.Fl I 4333bbe3f67SBaptiste Daroussinpatterns may be specified. 4343bbe3f67SBaptiste DaroussinAll lines in the change must match some pattern for the change to be 4353bbe3f67SBaptiste Daroussinignored. 4363bbe3f67SBaptiste DaroussinSee 4373bbe3f67SBaptiste Daroussin.Xr re_format 7 4383bbe3f67SBaptiste Daroussinfor more information on regular expression patterns. 439bcf91ad6SBaptiste Daroussin.It Fl i -ignore-case 4403bbe3f67SBaptiste DaroussinIgnores the case of letters. 4413bbe3f67SBaptiste DaroussinE.g., 4423bbe3f67SBaptiste Daroussin.Dq A 4433bbe3f67SBaptiste Daroussinwill compare equal to 4443bbe3f67SBaptiste Daroussin.Dq a . 445bcf91ad6SBaptiste Daroussin.It Fl l -paginate 4463bbe3f67SBaptiste DaroussinPass the output through 4473bbe3f67SBaptiste Daroussin.Xr pr 1 4483bbe3f67SBaptiste Daroussinto paginate it. 449bcf91ad6SBaptiste Daroussin.It Fl L Ar label Fl -label Ar label 4503bbe3f67SBaptiste DaroussinPrint 4513bbe3f67SBaptiste Daroussin.Ar label 4523bbe3f67SBaptiste Daroussininstead of the first (and second, if this option is specified twice) 4533bbe3f67SBaptiste Daroussinfile name and time in the context or unified diff header. 454bcf91ad6SBaptiste Daroussin.It Fl p -show-c-function 4553bbe3f67SBaptiste DaroussinWith unified and context diffs, show with each change 4563bbe3f67SBaptiste Daroussinthe first 40 characters of the last line before the context beginning 4573bbe3f67SBaptiste Daroussinwith a letter, an underscore or a dollar sign. 4588f79bd9bSTom JonesFor C and Objective-C source code following standard layout conventions, this 4598f79bd9bSTom Joneswill show the prototype of the function the change applies to. 460bcf91ad6SBaptiste Daroussin.It Fl T -initial-tab 4613bbe3f67SBaptiste DaroussinPrint a tab rather than a space before the rest of the line for the 4623bbe3f67SBaptiste Daroussinnormal, context or unified output formats. 4633bbe3f67SBaptiste DaroussinThis makes the alignment of tabs in the line consistent. 464bcf91ad6SBaptiste Daroussin.It Fl t -expand-tabs 4653bbe3f67SBaptiste DaroussinWill expand tabs in output lines. 4663bbe3f67SBaptiste DaroussinNormal or 4673bbe3f67SBaptiste Daroussin.Fl c 4683bbe3f67SBaptiste Daroussinoutput adds character(s) to the front of each line which may screw up 4693bbe3f67SBaptiste Daroussinthe indentation of the original source lines and make the output listing 4703bbe3f67SBaptiste Daroussindifficult to interpret. 4713bbe3f67SBaptiste DaroussinThis option will preserve the original source's indentation. 472*ab830de9SDag-Erling Smørgrav.It Fl w -ignore-all-space 4733bbe3f67SBaptiste DaroussinIs similar to 474bcf91ad6SBaptiste Daroussin.Fl b -ignore-space-change 4753bbe3f67SBaptiste Daroussinbut causes whitespace (blanks and tabs) to be totally ignored. 4763bbe3f67SBaptiste DaroussinE.g., 4773bbe3f67SBaptiste Daroussin.Dq if (\ \&a == b \&) 4783bbe3f67SBaptiste Daroussinwill compare equal to 4793bbe3f67SBaptiste Daroussin.Dq if(a==b) . 48064793e74SBaptiste Daroussin.It Fl W Ar number Fl -width Ar number 48164793e74SBaptiste DaroussinOutput at most 48264793e74SBaptiste Daroussin.Ar number 48379208b10SBaptiste Daroussincolumns when using side by side format. 48479208b10SBaptiste DaroussinThe default value is 130. 48553de23f4SDag-Erling SmørgravNote that unless 48653de23f4SDag-Erling Smørgrav.It Fl t 48753de23f4SDag-Erling Smørgravwas specified, 48853de23f4SDag-Erling Smørgrav.Nm 48953de23f4SDag-Erling Smørgravwill always align the second column to a tab stop, so values of 49053de23f4SDag-Erling Smørgrav.Fl -width 49153de23f4SDag-Erling Smørgravsmaller than approximately five times the value of 49253de23f4SDag-Erling Smørgrav.Fl -tabsize 49353de23f4SDag-Erling Smørgravmay yield surprising results. 494fddcb7b8SBaptiste Daroussin.It Fl -changed-group-format Ar GFMT 495fddcb7b8SBaptiste DaroussinFormat input groups in the provided 496fddcb7b8SBaptiste Daroussin.Pp 497fddcb7b8SBaptiste Daroussinthe format is a string with special keywords: 498fddcb7b8SBaptiste Daroussin.Bl -tag -width %< 499fddcb7b8SBaptiste Daroussin.It %< 500fddcb7b8SBaptiste Daroussinlines from FILE1 501fddcb7b8SBaptiste Daroussin.It %< 502fddcb7b8SBaptiste Daroussinlines from FILE2 503fddcb7b8SBaptiste Daroussin.El 504bcf91ad6SBaptiste Daroussin.It Fl -ignore-file-name-case 505bcf91ad6SBaptiste Daroussinignore case when comparing file names 5064ce4a0feSDag-Erling Smørgrav.It Fl -no-dereference 5074ce4a0feSDag-Erling Smørgravdo not follow symbolic links 508bcf91ad6SBaptiste Daroussin.It Fl -no-ignore-file-name-case 5094185d1f7SPin-Yi Kuodo not ignore case when comparing file names (default) 510bcf91ad6SBaptiste Daroussin.It Fl -normal 511bcf91ad6SBaptiste Daroussindefault diff output 512bcf91ad6SBaptiste Daroussin.It Fl -speed-large-files 513bcf91ad6SBaptiste Daroussinstub option for compatibility with GNU diff 514bcf91ad6SBaptiste Daroussin.It Fl -strip-trailing-cr 515bcf91ad6SBaptiste Daroussinstrip carriage return on input files 51664793e74SBaptiste Daroussin.It Fl -suppress-common-lines 51764793e74SBaptiste DaroussinDo not output common lines when using the side by side format 51864793e74SBaptiste Daroussin.It Fl -tabsize Ar number 519bcf91ad6SBaptiste DaroussinNumber of spaces representing a tab (default 8) 5203bbe3f67SBaptiste Daroussin.El 5213bbe3f67SBaptiste Daroussin.Pp 5223bbe3f67SBaptiste DaroussinDirectory comparison options: 5233bbe3f67SBaptiste Daroussin.Bl -tag -width Ds 524bcf91ad6SBaptiste Daroussin.It Fl N -new-file 5253bbe3f67SBaptiste DaroussinIf a file is found in only one directory, act as if it was found in the 5263bbe3f67SBaptiste Daroussinother directory too but was of zero size. 527bcf91ad6SBaptiste Daroussin.It Fl P -unidirectional-new-file 5283bbe3f67SBaptiste DaroussinIf a file is found only in 5293bbe3f67SBaptiste Daroussin.Ar dir2 , 5303bbe3f67SBaptiste Daroussinact as if it was found in 5313bbe3f67SBaptiste Daroussin.Ar dir1 5323bbe3f67SBaptiste Daroussintoo but was of zero size. 533bcf91ad6SBaptiste Daroussin.It Fl r -recursive 5343bbe3f67SBaptiste DaroussinCauses application of 5353bbe3f67SBaptiste Daroussin.Nm 5363bbe3f67SBaptiste Daroussinrecursively to common subdirectories encountered. 537bcf91ad6SBaptiste Daroussin.It Fl S Ar name Fl -starting-file Ar name 5383bbe3f67SBaptiste DaroussinRe-starts a directory 5393bbe3f67SBaptiste Daroussin.Nm 5403bbe3f67SBaptiste Daroussinin the middle, beginning with file 5413bbe3f67SBaptiste Daroussin.Ar name . 542bcf91ad6SBaptiste Daroussin.It Fl s -report-identical-files 5433bbe3f67SBaptiste DaroussinCauses 5443bbe3f67SBaptiste Daroussin.Nm 5453bbe3f67SBaptiste Daroussinto report files which are the same, which are otherwise not mentioned. 546bcf91ad6SBaptiste Daroussin.It Fl X Ar file Fl -exclude-from Ar file 5473bbe3f67SBaptiste DaroussinExclude files and subdirectories from comparison whose basenames match 5483bbe3f67SBaptiste Daroussinlines in 5493bbe3f67SBaptiste Daroussin.Ar file . 5503bbe3f67SBaptiste DaroussinMultiple 5513bbe3f67SBaptiste Daroussin.Fl X 5523bbe3f67SBaptiste Daroussinoptions may be specified. 553bcf91ad6SBaptiste Daroussin.It Fl x Ar pattern Fl -exclude Ar pattern 5543bbe3f67SBaptiste DaroussinExclude files and subdirectories from comparison whose basenames match 5553bbe3f67SBaptiste Daroussin.Ar pattern . 5563bbe3f67SBaptiste DaroussinPatterns are matched using shell-style globbing via 5573bbe3f67SBaptiste Daroussin.Xr fnmatch 3 . 5583bbe3f67SBaptiste DaroussinMultiple 5593bbe3f67SBaptiste Daroussin.Fl x 5603bbe3f67SBaptiste Daroussinoptions may be specified. 5613bbe3f67SBaptiste Daroussin.El 5623bbe3f67SBaptiste Daroussin.Pp 5633bbe3f67SBaptiste DaroussinIf both arguments are directories, 5643bbe3f67SBaptiste Daroussin.Nm 5653bbe3f67SBaptiste Daroussinsorts the contents of the directories by name, and then runs the 5663bbe3f67SBaptiste Daroussinregular file 5673bbe3f67SBaptiste Daroussin.Nm 5683bbe3f67SBaptiste Daroussinalgorithm, producing a change list, 5693bbe3f67SBaptiste Daroussinon text files which are different. 5703bbe3f67SBaptiste DaroussinBinary files which differ, 5713bbe3f67SBaptiste Daroussincommon subdirectories, and files which appear in only one directory 5723bbe3f67SBaptiste Daroussinare described as such. 5733bbe3f67SBaptiste DaroussinIn directory mode only regular files and directories are compared. 57479208b10SBaptiste DaroussinIf a non-regular file such as a device special file or FIFO is encountered, 57579208b10SBaptiste Daroussina diagnostic message is printed. 5763bbe3f67SBaptiste Daroussin.Pp 5773bbe3f67SBaptiste DaroussinIf only one of 5783bbe3f67SBaptiste Daroussin.Ar file1 5793bbe3f67SBaptiste Daroussinand 5803bbe3f67SBaptiste Daroussin.Ar file2 5813bbe3f67SBaptiste Daroussinis a directory, 5823bbe3f67SBaptiste Daroussin.Nm 5833bbe3f67SBaptiste Daroussinis applied to the non-directory file and the file contained in 5843bbe3f67SBaptiste Daroussinthe directory file with a filename that is the same as the 5853bbe3f67SBaptiste Daroussinlast component of the non-directory file. 5863bbe3f67SBaptiste Daroussin.Pp 5873bbe3f67SBaptiste DaroussinIf either 5883bbe3f67SBaptiste Daroussin.Ar file1 5893bbe3f67SBaptiste Daroussinor 5903bbe3f67SBaptiste Daroussin.Ar file2 5913bbe3f67SBaptiste Daroussinis 5923bbe3f67SBaptiste Daroussin.Sq - , 5933bbe3f67SBaptiste Daroussinthe standard input is 5943bbe3f67SBaptiste Daroussinused in its place. 5953bbe3f67SBaptiste Daroussin.Ss Output Style 5963bbe3f67SBaptiste DaroussinThe default (without 5973bbe3f67SBaptiste Daroussin.Fl e , 5983bbe3f67SBaptiste Daroussin.Fl c , 5993bbe3f67SBaptiste Daroussinor 600bcf91ad6SBaptiste Daroussin.Fl n -rcs 6013bbe3f67SBaptiste Daroussin.\" -C 6023bbe3f67SBaptiste Daroussinoptions) 6033bbe3f67SBaptiste Daroussinoutput contains lines of these forms, where 6043bbe3f67SBaptiste Daroussin.Va XX , YY , ZZ , QQ 6053bbe3f67SBaptiste Daroussinare line numbers respective of file order. 6063bbe3f67SBaptiste Daroussin.Pp 6073bbe3f67SBaptiste Daroussin.Bl -tag -width "XX,YYcZZ,QQ" -compact 6083bbe3f67SBaptiste Daroussin.It Li XX Ns Ic a Ns Li YY 6093bbe3f67SBaptiste DaroussinAt (the end of) line 6103bbe3f67SBaptiste Daroussin.Va XX 6113bbe3f67SBaptiste Daroussinof 6123bbe3f67SBaptiste Daroussin.Ar file1 , 6133bbe3f67SBaptiste Daroussinappend the contents 6143bbe3f67SBaptiste Daroussinof line 6153bbe3f67SBaptiste Daroussin.Va YY 6163bbe3f67SBaptiste Daroussinof 6173bbe3f67SBaptiste Daroussin.Ar file2 6183bbe3f67SBaptiste Daroussinto make them equal. 6193bbe3f67SBaptiste Daroussin.It Li XX Ns Ic a Ns Li YY,ZZ 6203bbe3f67SBaptiste DaroussinSame as above, but append the range of lines, 6213bbe3f67SBaptiste Daroussin.Va YY 6223bbe3f67SBaptiste Daroussinthrough 6233bbe3f67SBaptiste Daroussin.Va ZZ 6243bbe3f67SBaptiste Daroussinof 6253bbe3f67SBaptiste Daroussin.Ar file2 6263bbe3f67SBaptiste Daroussinto line 6273bbe3f67SBaptiste Daroussin.Va XX 6283bbe3f67SBaptiste Daroussinof file1. 6293bbe3f67SBaptiste Daroussin.It Li XX Ns Ic d Ns Li YY 6303bbe3f67SBaptiste DaroussinAt line 6313bbe3f67SBaptiste Daroussin.Va XX 6323bbe3f67SBaptiste Daroussindelete 6333bbe3f67SBaptiste Daroussinthe line. 6343bbe3f67SBaptiste DaroussinThe value 6353bbe3f67SBaptiste Daroussin.Va YY 6363bbe3f67SBaptiste Daroussintells to which line the change would bring 6373bbe3f67SBaptiste Daroussin.Ar file1 6383bbe3f67SBaptiste Daroussinin line with 6393bbe3f67SBaptiste Daroussin.Ar file2 . 6403bbe3f67SBaptiste Daroussin.It Li XX,YY Ns Ic d Ns Li ZZ 6413bbe3f67SBaptiste DaroussinDelete the range of lines 6423bbe3f67SBaptiste Daroussin.Va XX 6433bbe3f67SBaptiste Daroussinthrough 6443bbe3f67SBaptiste Daroussin.Va YY 6453bbe3f67SBaptiste Daroussinin 6463bbe3f67SBaptiste Daroussin.Ar file1 . 6473bbe3f67SBaptiste Daroussin.It Li XX Ns Ic c Ns Li YY 6483bbe3f67SBaptiste DaroussinChange the line 6493bbe3f67SBaptiste Daroussin.Va XX 6503bbe3f67SBaptiste Daroussinin 6513bbe3f67SBaptiste Daroussin.Ar file1 6523bbe3f67SBaptiste Daroussinto the line 6533bbe3f67SBaptiste Daroussin.Va YY 6543bbe3f67SBaptiste Daroussinin 6553bbe3f67SBaptiste Daroussin.Ar file2 . 6563bbe3f67SBaptiste Daroussin.It Li XX,YY Ns Ic c Ns Li ZZ 6573bbe3f67SBaptiste DaroussinReplace the range of specified lines with the line 6583bbe3f67SBaptiste Daroussin.Va ZZ . 6593bbe3f67SBaptiste Daroussin.It Li XX,YY Ns Ic c Ns Li ZZ,QQ 6603bbe3f67SBaptiste DaroussinReplace the range 6613bbe3f67SBaptiste Daroussin.Va XX , Ns Va YY 6623bbe3f67SBaptiste Daroussinfrom 6633bbe3f67SBaptiste Daroussin.Ar file1 6643bbe3f67SBaptiste Daroussinwith the range 6653bbe3f67SBaptiste Daroussin.Va ZZ , Ns Va QQ 6663bbe3f67SBaptiste Daroussinfrom 6673bbe3f67SBaptiste Daroussin.Ar file2 . 6683bbe3f67SBaptiste Daroussin.El 6693bbe3f67SBaptiste Daroussin.Pp 6703bbe3f67SBaptiste DaroussinThese lines resemble 6713bbe3f67SBaptiste Daroussin.Xr ed 1 6723bbe3f67SBaptiste Daroussinsubcommands to convert 6733bbe3f67SBaptiste Daroussin.Ar file1 6743bbe3f67SBaptiste Daroussininto 6753bbe3f67SBaptiste Daroussin.Ar file2 . 6763bbe3f67SBaptiste DaroussinThe line numbers before the action letters pertain to 6773bbe3f67SBaptiste Daroussin.Ar file1 ; 6783bbe3f67SBaptiste Daroussinthose after pertain to 6793bbe3f67SBaptiste Daroussin.Ar file2 . 6803bbe3f67SBaptiste DaroussinThus, by exchanging 6813bbe3f67SBaptiste Daroussin.Ic a 6823bbe3f67SBaptiste Daroussinfor 6833bbe3f67SBaptiste Daroussin.Ic d 6843bbe3f67SBaptiste Daroussinand reading the line in reverse order, one can also 6853bbe3f67SBaptiste Daroussindetermine how to convert 6863bbe3f67SBaptiste Daroussin.Ar file2 6873bbe3f67SBaptiste Daroussininto 6883bbe3f67SBaptiste Daroussin.Ar file1 . 6893bbe3f67SBaptiste DaroussinAs in 6903bbe3f67SBaptiste Daroussin.Xr ed 1 , 6913bbe3f67SBaptiste Daroussinidentical 6923bbe3f67SBaptiste Daroussinpairs (where num1 = num2) are abbreviated as a single 6933bbe3f67SBaptiste Daroussinnumber. 694f38702e5SCameron Katri.Sh ENVIRONMENT 695f38702e5SCameron Katri.Bl -tag -width DIFFCOLORS 696f38702e5SCameron Katri.It Ev DIFFCOLORS 697f38702e5SCameron KatriThe value of this variable is the form 698f38702e5SCameron Katri.Ar add Ns : Ns Ar rm , 699f38702e5SCameron Katriwhere 700f38702e5SCameron Katri.Ar add 701f38702e5SCameron Katriis the ASCII escape sequence for additions and 702f38702e5SCameron Katri.Ar rm 703f38702e5SCameron Katriis the ASCII escape sequence for deletions. 704f38702e5SCameron KatriIf this is unset, 705f38702e5SCameron Katri.Nm 706f38702e5SCameron Katriuses green for additions and red for removals. 707f38702e5SCameron Katri.El 7083bbe3f67SBaptiste Daroussin.Sh FILES 7093bbe3f67SBaptiste Daroussin.Bl -tag -width /tmp/diff.XXXXXXXX -compact 71079208b10SBaptiste Daroussin.It Pa /tmp/diff.XXXXXXXX 7113bbe3f67SBaptiste DaroussinTemporary file used when comparing a device or the standard input. 7123bbe3f67SBaptiste DaroussinNote that the temporary file is unlinked as soon as it is created 7133bbe3f67SBaptiste Daroussinso it will not show up in a directory listing. 7143bbe3f67SBaptiste Daroussin.El 7153bbe3f67SBaptiste Daroussin.Sh EXIT STATUS 7163bbe3f67SBaptiste DaroussinThe 7173bbe3f67SBaptiste Daroussin.Nm 7183bbe3f67SBaptiste Daroussinutility exits with one of the following values: 7193bbe3f67SBaptiste Daroussin.Pp 7203bbe3f67SBaptiste Daroussin.Bl -tag -width Ds -offset indent -compact 7213bbe3f67SBaptiste Daroussin.It 0 7223bbe3f67SBaptiste DaroussinNo differences were found. 7233bbe3f67SBaptiste Daroussin.It 1 7243bbe3f67SBaptiste DaroussinDifferences were found. 7253bbe3f67SBaptiste Daroussin.It >1 7263bbe3f67SBaptiste DaroussinAn error occurred. 7273bbe3f67SBaptiste Daroussin.El 7288cf449dbSTom Jones.Pp 7298cf449dbSTom JonesThe 7308cf449dbSTom Jones.Fl -help 7318cf449dbSTom Jonesand 7328cf449dbSTom Jones.Fl -version 7338cf449dbSTom Jonesoptions exit with a status of 0. 734204fa3b0SFernando Apesteguía.Sh EXAMPLES 735204fa3b0SFernando ApesteguíaCompare 736204fa3b0SFernando Apesteguía.Pa old_dir 737204fa3b0SFernando Apesteguíaand 738204fa3b0SFernando Apesteguía.Pa new_dir 739204fa3b0SFernando Apesteguíarecursively generating an unified diff and treating files found only in one 740204fa3b0SFernando Apesteguíaof those directories as new files: 741204fa3b0SFernando Apesteguía.Bd -literal -offset indent 742204fa3b0SFernando Apesteguía$ diff -ruN /path/to/old_dir /path/to/new_dir 743204fa3b0SFernando Apesteguía.Ed 744204fa3b0SFernando Apesteguía.Pp 745204fa3b0SFernando ApesteguíaSame as above but excluding files matching the expressions 746204fa3b0SFernando Apesteguía.Dq *.h 747204fa3b0SFernando Apesteguíaand 748204fa3b0SFernando Apesteguía.Dq *.c : 749204fa3b0SFernando Apesteguía.Bd -literal -offset indent 750204fa3b0SFernando Apesteguía$ diff -ruN -x '*.h' -x '*.c' /path/to/old_dir /path/to/new_dir 751204fa3b0SFernando Apesteguía.Ed 752204fa3b0SFernando Apesteguía.Pp 753204fa3b0SFernando ApesteguíaShow a single line indicating if the files differ: 754204fa3b0SFernando Apesteguía.Bd -literal -offset indent 755204fa3b0SFernando Apesteguía$ diff -q /boot/loader.conf /boot/defaults/loader.conf 756204fa3b0SFernando ApesteguíaFiles /boot/loader.conf and /boot/defaults/loader.conf differ 757204fa3b0SFernando Apesteguía.Ed 758204fa3b0SFernando Apesteguía.Pp 759204fa3b0SFernando ApesteguíaAssuming a file named 760204fa3b0SFernando Apesteguía.Pa example.txt 761204fa3b0SFernando Apesteguíawith the following contents: 762204fa3b0SFernando Apesteguía.Bd -literal -offset indent 763204fa3b0SFernando ApesteguíaFreeBSD is an operating system 764204fa3b0SFernando ApesteguíaLinux is a kernel 765204fa3b0SFernando ApesteguíaOpenBSD is an operating system 766204fa3b0SFernando Apesteguía.Ed 767204fa3b0SFernando Apesteguía.Pp 768204fa3b0SFernando ApesteguíaCompare stdin with 769204fa3b0SFernando Apesteguía.Pa example.txt 770204fa3b0SFernando Apesteguíaexcluding from the comparison those lines containing either 771204fa3b0SFernando Apesteguía.Qq Linux 772204fa3b0SFernando Apesteguíaor 773204fa3b0SFernando Apesteguía.Qq Open : 774204fa3b0SFernando Apesteguía.Bd -literal -offset indent 775204fa3b0SFernando Apesteguía$ echo "FreeBSD is an operating system" | diff -q -I 'Linux|Open' example.txt - 776204fa3b0SFernando Apesteguía.Ed 7773bbe3f67SBaptiste Daroussin.Sh SEE ALSO 7783bbe3f67SBaptiste Daroussin.Xr cmp 1 , 7793bbe3f67SBaptiste Daroussin.Xr comm 1 , 7803bbe3f67SBaptiste Daroussin.Xr diff3 1 , 7813bbe3f67SBaptiste Daroussin.Xr ed 1 , 7823bbe3f67SBaptiste Daroussin.Xr patch 1 , 783933870f0SBaptiste Daroussin.Xr pr 1 , 7843bbe3f67SBaptiste Daroussin.Xr sdiff 1 7853bbe3f67SBaptiste Daroussin.Rs 7863bbe3f67SBaptiste Daroussin.%A James W. Hunt 7873bbe3f67SBaptiste Daroussin.%A M. Douglas McIlroy 7883bbe3f67SBaptiste Daroussin.%T "An Algorithm for Differential File Comparison" 7893bbe3f67SBaptiste Daroussin.%J Computing Science Technical Report 7903bbe3f67SBaptiste Daroussin.%Q Bell Laboratories 41 7913bbe3f67SBaptiste Daroussin.%D June 1976 7923bbe3f67SBaptiste Daroussin.Re 7933bbe3f67SBaptiste Daroussin.Sh STANDARDS 7943bbe3f67SBaptiste DaroussinThe 7953bbe3f67SBaptiste Daroussin.Nm 7963bbe3f67SBaptiste Daroussinutility is compliant with the 7973bbe3f67SBaptiste Daroussin.St -p1003.1-2008 7983bbe3f67SBaptiste Daroussinspecification. 7993bbe3f67SBaptiste Daroussin.Pp 8003bbe3f67SBaptiste DaroussinThe flags 801d9a9f23dSDag-Erling Smørgrav.Op Fl AaDdIiLlNnPpqSsTtwXxy 8023bbe3f67SBaptiste Daroussinare extensions to that specification. 8033bbe3f67SBaptiste Daroussin.Sh HISTORY 8043bbe3f67SBaptiste DaroussinA 8053bbe3f67SBaptiste Daroussin.Nm 8063bbe3f67SBaptiste Daroussincommand appeared in 8073bbe3f67SBaptiste Daroussin.At v6 . 80887740ff2SDavid E. O'BrienThe 80987740ff2SDavid E. O'Brien.Nm 8106561c0ecSDag-Erling Smørgravimplementation used in 8116561c0ecSDag-Erling Smørgrav.Fx 8126561c0ecSDag-Erling Smørgravwas GNU diff until 8136561c0ecSDag-Erling Smørgrav.Fx 11.4 . 8146561c0ecSDag-Erling SmørgravThis was replaced in 81587740ff2SDavid E. O'Brien.Fx 12.0 8166561c0ecSDag-Erling Smørgravby a BSD-licensed implementation written by 8176561c0ecSDag-Erling Smørgrav.An Todd Miller . 8186561c0ecSDag-Erling SmørgravSome GNUisms were lost in the process. 819d9a9f23dSDag-Erling Smørgrav.Pp 820d9a9f23dSDag-Erling Smørgravlibdiff was imported from the Game of Trees version control system and default 821d9a9f23dSDag-Erling Smørgravalgorithm was changed to Myers for FreeBSD 15. 822