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*d9a9f23dSDag-Erling Smørgrav.Dd March 7, 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 43*d9a9f23dSDag-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 5578b83a1eSEnji Cooper.Op Fl -no-ignore-file-name-case 563bbe3f67SBaptiste Daroussin.Op Fl -normal 577dacb9e7SEnji Cooper.Op Fl -rcs 587dacb9e7SEnji Cooper.Op Fl -show-c-function 597dacb9e7SEnji Cooper.Op Fl -starting-file 60a077708dSBaptiste Daroussin.Op Fl -speed-large-files 613bbe3f67SBaptiste Daroussin.Op Fl -strip-trailing-cr 6243fbd654SKyle Evans.Op Fl -tabsize Ar number 637dacb9e7SEnji Cooper.Op Fl -text 647dacb9e7SEnji Cooper.Op Fl -unified 657dacb9e7SEnji Cooper.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern 66e51aabf8SPiotr Pawel Stefaniak.Op Fl F Ar pattern | Fl -show-function-line Ar pattern 677dacb9e7SEnji Cooper.Op Fl L Ar label | Fl -label Ar label 683bbe3f67SBaptiste Daroussin.Ar file1 file2 693bbe3f67SBaptiste Daroussin.Nm diff 70e68edb8cSKyle Evans.Op Fl aBbdilpTtw 71*d9a9f23dSDag-Erling Smørgrav.Op Fl A Ar algo | Fl -algorithm Ar algo 727dacb9e7SEnji Cooper.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern 73e51aabf8SPiotr Pawel Stefaniak.Op Fl F Ar pattern | Fl -show-function-line Ar pattern 747dacb9e7SEnji Cooper.Op Fl L Ar label | Fl -label Ar label 757dacb9e7SEnji Cooper.Op Fl -brief 76f38702e5SCameron Katri.Op Fl -color Ns = Ns Ar when 77fddcb7b8SBaptiste Daroussin.Op Fl -changed-group-format Ar GFMT 787dacb9e7SEnji Cooper.Op Fl -ed 797dacb9e7SEnji Cooper.Op Fl -expand-tabs 807dacb9e7SEnji Cooper.Op Fl -forward-ed 817dacb9e7SEnji Cooper.Op Fl -ignore-all-space 823bbe3f67SBaptiste Daroussin.Op Fl -ignore-case 837dacb9e7SEnji Cooper.Op Fl -ignore-space-change 847dacb9e7SEnji Cooper.Op Fl -initial-tab 857dacb9e7SEnji Cooper.Op Fl -minimal 8678b83a1eSEnji Cooper.Op Fl -no-ignore-file-name-case 873bbe3f67SBaptiste Daroussin.Op Fl -normal 887dacb9e7SEnji Cooper.Op Fl -paginate 897dacb9e7SEnji Cooper.Op Fl -rcs 907dacb9e7SEnji Cooper.Op Fl -show-c-function 91a077708dSBaptiste Daroussin.Op Fl -speed-large-files 927dacb9e7SEnji Cooper.Op Fl -starting-file 933bbe3f67SBaptiste Daroussin.Op Fl -strip-trailing-cr 9443fbd654SKyle Evans.Op Fl -tabsize Ar number 957dacb9e7SEnji Cooper.Op Fl -text 967dacb9e7SEnji Cooper.Fl C Ar number | -context Ar number 973bbe3f67SBaptiste Daroussin.Ar file1 file2 983bbe3f67SBaptiste Daroussin.Nm diff 99e68edb8cSKyle Evans.Op Fl aBbdiltw 100*d9a9f23dSDag-Erling Smørgrav.Op Fl A Ar algo | Fl -algorithm Ar algo 1017dacb9e7SEnji Cooper.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern 1027dacb9e7SEnji Cooper.Op Fl -brief 103f38702e5SCameron Katri.Op Fl -color Ns = Ns Ar when 104fddcb7b8SBaptiste Daroussin.Op Fl -changed-group-format Ar GFMT 1057dacb9e7SEnji Cooper.Op Fl -ed 1067dacb9e7SEnji Cooper.Op Fl -expand-tabs 1077dacb9e7SEnji Cooper.Op Fl -forward-ed 1087dacb9e7SEnji Cooper.Op Fl -ignore-all-space 1093bbe3f67SBaptiste Daroussin.Op Fl -ignore-case 1107dacb9e7SEnji Cooper.Op Fl -ignore-space-change 1117dacb9e7SEnji Cooper.Op Fl -initial-tab 1127dacb9e7SEnji Cooper.Op Fl -minimal 11378b83a1eSEnji Cooper.Op Fl -no-ignore-file-name-case 1143bbe3f67SBaptiste Daroussin.Op Fl -normal 1157dacb9e7SEnji Cooper.Op Fl -paginate 1167dacb9e7SEnji Cooper.Op Fl -rcs 1177dacb9e7SEnji Cooper.Op Fl -show-c-function 118a077708dSBaptiste Daroussin.Op Fl -speed-large-files 1197dacb9e7SEnji Cooper.Op Fl -starting-file 1203bbe3f67SBaptiste Daroussin.Op Fl -strip-trailing-cr 12143fbd654SKyle Evans.Op Fl -tabsize Ar number 1227dacb9e7SEnji Cooper.Op Fl -text 1237dacb9e7SEnji Cooper.Fl D Ar string | Fl -ifdef Ar string 1243bbe3f67SBaptiste Daroussin.Ar file1 file2 1253bbe3f67SBaptiste Daroussin.Nm diff 126e68edb8cSKyle Evans.Op Fl aBbdilpTtw 127*d9a9f23dSDag-Erling Smørgrav.Op Fl A Ar algo | Fl -algorithm Ar algo 1287dacb9e7SEnji Cooper.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern 129e51aabf8SPiotr Pawel Stefaniak.Op Fl F Ar pattern | Fl -show-function-line Ar pattern 1307dacb9e7SEnji Cooper.Op Fl L Ar label | Fl -label Ar label 1317dacb9e7SEnji Cooper.Op Fl -brief 132f38702e5SCameron Katri.Op Fl -color Ns = Ns Ar when 133fddcb7b8SBaptiste Daroussin.Op Fl -changed-group-format Ar GFMT 1347dacb9e7SEnji Cooper.Op Fl -ed 1357dacb9e7SEnji Cooper.Op Fl -expand-tabs 1367dacb9e7SEnji Cooper.Op Fl -forward-ed 1377dacb9e7SEnji Cooper.Op Fl -ignore-all-space 1383bbe3f67SBaptiste Daroussin.Op Fl -ignore-case 1397dacb9e7SEnji Cooper.Op Fl -ignore-space-change 1407dacb9e7SEnji Cooper.Op Fl -initial-tab 1417dacb9e7SEnji Cooper.Op Fl -minimal 14278b83a1eSEnji Cooper.Op Fl -no-ignore-file-name-case 1433bbe3f67SBaptiste Daroussin.Op Fl -normal 1447dacb9e7SEnji Cooper.Op Fl -paginate 1457dacb9e7SEnji Cooper.Op Fl -rcs 1467dacb9e7SEnji Cooper.Op Fl -show-c-function 147a077708dSBaptiste Daroussin.Op Fl -speed-large-files 1487dacb9e7SEnji Cooper.Op Fl -starting-file 1493bbe3f67SBaptiste Daroussin.Op Fl -strip-trailing-cr 15043fbd654SKyle Evans.Op Fl -tabsize Ar number 1517dacb9e7SEnji Cooper.Op Fl -text 1527dacb9e7SEnji Cooper.Fl U Ar number | Fl -unified Ar number 1533bbe3f67SBaptiste Daroussin.Ar file1 file2 1543bbe3f67SBaptiste Daroussin.Nm diff 155e68edb8cSKyle Evans.Op Fl aBbdilNPprsTtw 1563bbe3f67SBaptiste Daroussin.Oo 1573bbe3f67SBaptiste Daroussin.Fl c | e | f | 1583bbe3f67SBaptiste Daroussin.Fl n | q | u 1593bbe3f67SBaptiste Daroussin.Oc 160*d9a9f23dSDag-Erling Smørgrav.Op Fl A Ar algo | Fl -algorithm Ar algo 1617dacb9e7SEnji Cooper.Op Fl -brief 162f38702e5SCameron Katri.Op Fl -color Ns = Ns Ar when 163fddcb7b8SBaptiste Daroussin.Op Fl -changed-group-format Ar GFMT 1647dacb9e7SEnji Cooper.Op Fl -context 1657dacb9e7SEnji Cooper.Op Fl -ed 1667dacb9e7SEnji Cooper.Op Fl -expand-tabs 1677dacb9e7SEnji Cooper.Op Fl -forward-ed 1687dacb9e7SEnji Cooper.Op Fl -ignore-all-space 1693bbe3f67SBaptiste Daroussin.Op Fl -ignore-case 1707dacb9e7SEnji Cooper.Op Fl -ignore-space-change 1717dacb9e7SEnji Cooper.Op Fl -initial-tab 1727dacb9e7SEnji Cooper.Op Fl -minimal 1737dacb9e7SEnji Cooper.Op Fl -new-file 17478b83a1eSEnji Cooper.Op Fl -no-ignore-file-name-case 1753bbe3f67SBaptiste Daroussin.Op Fl -normal 1767dacb9e7SEnji Cooper.Op Fl -paginate 1777dacb9e7SEnji Cooper.Op Fl -rcs 1787dacb9e7SEnji Cooper.Op Fl -recursive 1797dacb9e7SEnji Cooper.Op Fl -report-identical-files 1807dacb9e7SEnji Cooper.Op Fl -show-c-function 181a077708dSBaptiste Daroussin.Op Fl -speed-large-files 1829ba27624SEnji Cooper.Op Fl -strip-trailing-cr 18343fbd654SKyle Evans.Op Fl -tabsize Ar number 1847dacb9e7SEnji Cooper.Op Fl -text 1857dacb9e7SEnji Cooper.Op Fl -unidirectional-new-file 1867dacb9e7SEnji Cooper.Op Fl -unified 1877dacb9e7SEnji Cooper.Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern 188e51aabf8SPiotr Pawel Stefaniak.Op Fl F Ar pattern | Fl -show-function-line Ar pattern 1893bbe3f67SBaptiste Daroussin.Bk -words 1907dacb9e7SEnji Cooper.Op Fl L Ar label | Fl -label Ar label 1917dacb9e7SEnji Cooper.Op Fl S Ar name | Fl -starting-file Ar name 1927dacb9e7SEnji Cooper.Op Fl X Ar file | Fl -exclude-from Ar file 1937dacb9e7SEnji Cooper.Op Fl x Ar pattern | Fl -exclude Ar pattern 1943bbe3f67SBaptiste Daroussin.Ek 1953bbe3f67SBaptiste Daroussin.Ar dir1 dir2 19664793e74SBaptiste Daroussin.Nm diff 19764793e74SBaptiste Daroussin.Op Fl aBbditwW 198f38702e5SCameron Katri.Op Fl -color Ns = Ns Ar when 199469635f6SMateusz Piotrowski.Op Fl -expand-tabs 200469635f6SMateusz Piotrowski.Op Fl -ignore-all-blanks 201469635f6SMateusz Piotrowski.Op Fl -ignore-blank-lines 202469635f6SMateusz Piotrowski.Op Fl -ignore-case 203469635f6SMateusz Piotrowski.Op Fl -minimal 204469635f6SMateusz Piotrowski.Op Fl -no-ignore-file-name-case 205469635f6SMateusz Piotrowski.Op Fl -strip-trailing-cr 206469635f6SMateusz Piotrowski.Op Fl -suppress-common-lines 20743fbd654SKyle Evans.Op Fl -tabsize Ar number 208469635f6SMateusz Piotrowski.Op Fl -text 209469635f6SMateusz Piotrowski.Op Fl -width 21064793e74SBaptiste Daroussin.Fl y | Fl -side-by-side 21164793e74SBaptiste Daroussin.Ar file1 file2 2128cf449dbSTom Jones.Nm diff 2138cf449dbSTom Jones.Op Fl -help 2148cf449dbSTom Jones.Op Fl -version 2153bbe3f67SBaptiste Daroussin.Sh DESCRIPTION 2163bbe3f67SBaptiste DaroussinThe 2173bbe3f67SBaptiste Daroussin.Nm 2183bbe3f67SBaptiste Daroussinutility compares the contents of 2193bbe3f67SBaptiste Daroussin.Ar file1 2203bbe3f67SBaptiste Daroussinand 2213bbe3f67SBaptiste Daroussin.Ar file2 2223bbe3f67SBaptiste Daroussinand writes to the standard output the list of changes necessary to 2233bbe3f67SBaptiste Daroussinconvert one file into the other. 2243bbe3f67SBaptiste DaroussinNo output is produced if the files are identical. 2253bbe3f67SBaptiste Daroussin.Pp 2263bbe3f67SBaptiste DaroussinOutput options (mutually exclusive): 2273bbe3f67SBaptiste Daroussin.Bl -tag -width Ds 228bcf91ad6SBaptiste Daroussin.It Fl C Ar number Fl -context Ar number 2293bbe3f67SBaptiste DaroussinLike 2303bbe3f67SBaptiste Daroussin.Fl c 2313bbe3f67SBaptiste Daroussinbut produces a diff with 2323bbe3f67SBaptiste Daroussin.Ar number 2333bbe3f67SBaptiste Daroussinlines of context. 2343bbe3f67SBaptiste Daroussin.It Fl c 2353bbe3f67SBaptiste DaroussinProduces a diff with 3 lines of context. 2363bbe3f67SBaptiste DaroussinWith 2373bbe3f67SBaptiste Daroussin.Fl c 2383bbe3f67SBaptiste Daroussinthe output format is modified slightly: 2393bbe3f67SBaptiste Daroussinthe output begins with identification of the files involved and 2403bbe3f67SBaptiste Daroussintheir creation dates and then each change is separated 2413bbe3f67SBaptiste Daroussinby a line with fifteen 2423bbe3f67SBaptiste Daroussin.Li * Ns 's . 2433bbe3f67SBaptiste DaroussinThe lines removed from 2443bbe3f67SBaptiste Daroussin.Ar file1 2453bbe3f67SBaptiste Daroussinare marked with 2463bbe3f67SBaptiste Daroussin.Sq \&-\ \& ; 2473bbe3f67SBaptiste Daroussinthose added to 2483bbe3f67SBaptiste Daroussin.Ar file2 2493bbe3f67SBaptiste Daroussinare marked 25079208b10SBaptiste Daroussin.Sq +\ \& . 2513bbe3f67SBaptiste DaroussinLines which are changed from one file to the other are marked in 2523bbe3f67SBaptiste Daroussinboth files with 2533bbe3f67SBaptiste Daroussin.Sq !\ \& . 2543bbe3f67SBaptiste DaroussinChanges which lie within 3 lines of each other are grouped together on 2553bbe3f67SBaptiste Daroussinoutput. 256bcf91ad6SBaptiste Daroussin.It Fl D Ar string Fl -ifdef Ar string 2573bbe3f67SBaptiste DaroussinCreates a merged version of 2583bbe3f67SBaptiste Daroussin.Ar file1 2593bbe3f67SBaptiste Daroussinand 2603bbe3f67SBaptiste Daroussin.Ar file2 2613bbe3f67SBaptiste Daroussinon the standard output, with C preprocessor controls included so that 2623bbe3f67SBaptiste Daroussina compilation of the result without defining 2633bbe3f67SBaptiste Daroussin.Ar string 2643bbe3f67SBaptiste Daroussinis equivalent to compiling 2653bbe3f67SBaptiste Daroussin.Ar file1 , 2663bbe3f67SBaptiste Daroussinwhile defining 2673bbe3f67SBaptiste Daroussin.Ar string 2683bbe3f67SBaptiste Daroussinwill yield 2693bbe3f67SBaptiste Daroussin.Ar file2 . 270bcf91ad6SBaptiste Daroussin.It Fl e -ed 2713bbe3f67SBaptiste DaroussinProduces output in a form suitable as input for the editor utility, 2723bbe3f67SBaptiste Daroussin.Xr ed 1 , 2733bbe3f67SBaptiste Daroussinwhich can then be used to convert file1 into file2. 2743bbe3f67SBaptiste Daroussin.Pp 2753bbe3f67SBaptiste DaroussinExtra commands are added to the output when comparing directories with 2763bbe3f67SBaptiste Daroussin.Fl e , 2773bbe3f67SBaptiste Daroussinso that the result is a 2783bbe3f67SBaptiste Daroussin.Xr sh 1 2793bbe3f67SBaptiste Daroussinscript for converting text files which are common to the two directories 2803bbe3f67SBaptiste Daroussinfrom their state in 2813bbe3f67SBaptiste Daroussin.Ar dir1 2823bbe3f67SBaptiste Daroussinto their state in 2833bbe3f67SBaptiste Daroussin.Ar dir2 . 284*d9a9f23dSDag-Erling SmørgravNote that when comparing directories with 285*d9a9f23dSDag-Erling Smørgrav.Fl e , 286*d9a9f23dSDag-Erling Smørgravthe resulting file may no longer be interpreted as an 287*d9a9f23dSDag-Erling Smørgrav.Xr ed 1 288*d9a9f23dSDag-Erling Smørgravscript. 289*d9a9f23dSDag-Erling SmørgravOutput is added to indicate which file each set of 290*d9a9f23dSDag-Erling Smørgrav.Xr ed 1 291*d9a9f23dSDag-Erling Smørgravcommands applies to. 292*d9a9f23dSDag-Erling SmørgravThese hunks can be manually extracted to produce an 293*d9a9f23dSDag-Erling Smørgrav.Xr ed 1 294*d9a9f23dSDag-Erling Smørgravscript, which can also be applied with 295*d9a9f23dSDag-Erling Smørgrav.Xr patch 1 . 296bcf91ad6SBaptiste Daroussin.It Fl f -forward-ed 2973bbe3f67SBaptiste DaroussinIdentical output to that of the 2983bbe3f67SBaptiste Daroussin.Fl e 2993bbe3f67SBaptiste Daroussinflag, but in reverse order. 3003bbe3f67SBaptiste DaroussinIt cannot be digested by 3013bbe3f67SBaptiste Daroussin.Xr ed 1 . 3028cf449dbSTom Jones.It Fl -help 3038cf449dbSTom JonesThis option prints a summary to stdout and exits with status 0. 3043bbe3f67SBaptiste Daroussin.It Fl n 3053bbe3f67SBaptiste DaroussinProduces a script similar to that of 3063bbe3f67SBaptiste Daroussin.Fl e , 3073bbe3f67SBaptiste Daroussinbut in the opposite order and with a count of changed lines on each 3083bbe3f67SBaptiste Daroussininsert or delete command. 309204fa3b0SFernando ApesteguíaThis is the form used by rcsdiff. 310bcf91ad6SBaptiste Daroussin.It Fl q -brief 3113bbe3f67SBaptiste DaroussinJust print a line when the files differ. 3123bbe3f67SBaptiste DaroussinDoes not output a list of changes. 313bcf91ad6SBaptiste Daroussin.It Fl U Ar number Fl -unified Ar number 3143bbe3f67SBaptiste DaroussinLike 3153bbe3f67SBaptiste Daroussin.Fl u 3163bbe3f67SBaptiste Daroussinbut produces a diff with 3173bbe3f67SBaptiste Daroussin.Ar number 3183bbe3f67SBaptiste Daroussinlines of context. 3193bbe3f67SBaptiste Daroussin.It Fl u 3203bbe3f67SBaptiste DaroussinProduces a 3213bbe3f67SBaptiste Daroussin.Em unified 3223bbe3f67SBaptiste Daroussindiff with 3 lines of context. 3233bbe3f67SBaptiste DaroussinA unified diff is similar to the context diff produced by the 3243bbe3f67SBaptiste Daroussin.Fl c 3253bbe3f67SBaptiste Daroussinoption. 3263bbe3f67SBaptiste DaroussinHowever, unlike with 3273bbe3f67SBaptiste Daroussin.Fl c , 3283bbe3f67SBaptiste Daroussinall lines to be changed (added and/or removed) are present in 3293bbe3f67SBaptiste Daroussina single section. 3308cf449dbSTom Jones.It Fl -version 3318cf449dbSTom JonesThis option prints a version string to stdout and exits with status 0. 33264793e74SBaptiste Daroussin.It Fl y Fl -side-by-side 33379208b10SBaptiste DaroussinOutput in two columns with a marker between them. 33479208b10SBaptiste DaroussinThe marker can be one 33564793e74SBaptiste Daroussinof the following: 33664793e74SBaptiste Daroussin.Pp 33764793e74SBaptiste Daroussin.Bl -tag -width Ds -offset indent -compact 33864793e74SBaptiste Daroussin.It space 33964793e74SBaptiste DaroussinCorresponding lines are identical. 34064793e74SBaptiste Daroussin.It '|' 34164793e74SBaptiste DaroussinCorresponding lines are different. 34264793e74SBaptiste Daroussin.It '<' 34364793e74SBaptiste DaroussinFiles differ and only the first file contains the line. 34464793e74SBaptiste Daroussin.It '>' 34564793e74SBaptiste DaroussinFiles differ and only the second file contains the line. 34664793e74SBaptiste Daroussin.El 3473bbe3f67SBaptiste Daroussin.El 3483bbe3f67SBaptiste Daroussin.Pp 3493bbe3f67SBaptiste DaroussinComparison options: 3503bbe3f67SBaptiste Daroussin.Bl -tag -width Ds 351*d9a9f23dSDag-Erling Smørgrav.It Fl A Ar algo, Fl -algorithm Ar algo 352*d9a9f23dSDag-Erling SmørgravConfigure the algorithm used when comparing files. 353*d9a9f23dSDag-Erling Smørgrav.Nm 354*d9a9f23dSDag-Erling Smørgravsupports 3 algorithms: 355*d9a9f23dSDag-Erling Smørgrav.Pp 356*d9a9f23dSDag-Erling Smørgrav.Bl -tag -width Ds -compact 357*d9a9f23dSDag-Erling Smørgrav.It Cm myers 358*d9a9f23dSDag-Erling SmørgravThe Myers diff algorithm finds the shortest edit which transforms one 359*d9a9f23dSDag-Erling Smørgravinput into the other. 360*d9a9f23dSDag-Erling SmørgravIt generally runs in O(N+D\(S2) time, requiring O(N) space, where N is 361*d9a9f23dSDag-Erling Smørgravthe sum of the lengths of the inputs and D is the length of the 362*d9a9f23dSDag-Erling Smørgravdifference between them, with a theoretical O(N\(pcD) worst case. 363*d9a9f23dSDag-Erling SmørgravIf it encounters worst-case input, the implementation used by 364*d9a9f23dSDag-Erling Smørgrav.Nm 365*d9a9f23dSDag-Erling Smørgravfalls back to a less optimal but faster algorithm. 366*d9a9f23dSDag-Erling Smørgrav.It Cm patience 367*d9a9f23dSDag-Erling SmørgravThe Patience variant of the Myers algorithm attempts to create more 368*d9a9f23dSDag-Erling Smørgravaesthetically pleasing diff output by logically grouping lines. 369*d9a9f23dSDag-Erling Smørgrav.It Cm stone 370*d9a9f23dSDag-Erling SmørgravThe Stone algorithm (commonly known as Hunt-McIlroy or Hunt-Szymanski) 371*d9a9f23dSDag-Erling Smørgravlooks for the longest common subsequence between compared files. 372*d9a9f23dSDag-Erling SmørgravStone encounters worst case performance when there are long common 373*d9a9f23dSDag-Erling Smørgravsubsequences. 374*d9a9f23dSDag-Erling SmørgravIn large files this can lead to a significant performance impact. 375*d9a9f23dSDag-Erling SmørgravThe Stone algorithm is maintained for compatibility. 376*d9a9f23dSDag-Erling Smørgrav.El 377*d9a9f23dSDag-Erling Smørgrav.Pp 378*d9a9f23dSDag-Erling SmørgravThe 379*d9a9f23dSDag-Erling Smørgrav.Nm 380*d9a9f23dSDag-Erling Smørgravutility defaults to the Myers algorithm, but will fall back to the 381*d9a9f23dSDag-Erling SmørgravStone algorithm if the input or output options are not supported by 382*d9a9f23dSDag-Erling Smørgravthe Myers implementation. 383bcf91ad6SBaptiste Daroussin.It Fl a -text 38479208b10SBaptiste DaroussinTreat all files as ASCII text. 3853bbe3f67SBaptiste DaroussinNormally 3863bbe3f67SBaptiste Daroussin.Nm 3873bbe3f67SBaptiste Daroussinwill simply print 3883bbe3f67SBaptiste Daroussin.Dq Binary files ... differ 3893bbe3f67SBaptiste Daroussinif files contain binary characters. 3903bbe3f67SBaptiste DaroussinUse of this option forces 3913bbe3f67SBaptiste Daroussin.Nm 3923bbe3f67SBaptiste Daroussinto produce a diff. 393e68edb8cSKyle Evans.It Fl B Fl -ignore-blank-lines 394e68edb8cSKyle EvansCauses chunks that include only blank lines to be ignored. 3958ccef193SBaptiste Daroussin.It Fl b -ignore-space-change 3963bbe3f67SBaptiste DaroussinCauses trailing blanks (spaces and tabs) to be ignored, and other 3973bbe3f67SBaptiste Daroussinstrings of blanks to compare equal. 398f38702e5SCameron Katri.It Fl -color= Ns Oo Ar when Oc 399f38702e5SCameron KatriColor the additions green, and removals red, or the value in the 400f38702e5SCameron Katri.Ev DIFFCOLORS 401f38702e5SCameron Katrienvironment variable. 402f38702e5SCameron KatriThe possible values of 403f38702e5SCameron Katri.Ar when 404f38702e5SCameron Katriare 405f38702e5SCameron Katri.Dq Cm never , 406f38702e5SCameron Katri.Dq Cm always 407f38702e5SCameron Katriand 408f38702e5SCameron Katri.Dq Cm auto . 409f38702e5SCameron Katri.Cm auto 410f38702e5SCameron Katriwill use color if the output is a tty and the 411f38702e5SCameron Katri.Ev COLORTERM 412f38702e5SCameron Katrienvironment variable is set to a non-empty string. 413bcf91ad6SBaptiste Daroussin.It Fl d -minimal 4143bbe3f67SBaptiste DaroussinTry very hard to produce a diff as small as possible. 4153bbe3f67SBaptiste DaroussinThis may consume a lot of processing power and memory when processing 4163bbe3f67SBaptiste Daroussinlarge files with many changes. 417e51aabf8SPiotr Pawel Stefaniak.It Fl F Ar pattern, Fl -show-function-line Ar pattern 418e51aabf8SPiotr Pawel StefaniakLike 419e51aabf8SPiotr Pawel Stefaniak.Fl p, 420e51aabf8SPiotr Pawel Stefaniakbut display the last line that matches provided pattern. 421bcf91ad6SBaptiste Daroussin.It Fl I Ar pattern Fl -ignore-matching-lines Ar pattern 4223bbe3f67SBaptiste DaroussinIgnores changes, insertions, and deletions whose lines match the 4233bbe3f67SBaptiste Daroussinextended regular expression 4243bbe3f67SBaptiste Daroussin.Ar pattern . 4253bbe3f67SBaptiste DaroussinMultiple 4263bbe3f67SBaptiste Daroussin.Fl I 4273bbe3f67SBaptiste Daroussinpatterns may be specified. 4283bbe3f67SBaptiste DaroussinAll lines in the change must match some pattern for the change to be 4293bbe3f67SBaptiste Daroussinignored. 4303bbe3f67SBaptiste DaroussinSee 4313bbe3f67SBaptiste Daroussin.Xr re_format 7 4323bbe3f67SBaptiste Daroussinfor more information on regular expression patterns. 433bcf91ad6SBaptiste Daroussin.It Fl i -ignore-case 4343bbe3f67SBaptiste DaroussinIgnores the case of letters. 4353bbe3f67SBaptiste DaroussinE.g., 4363bbe3f67SBaptiste Daroussin.Dq A 4373bbe3f67SBaptiste Daroussinwill compare equal to 4383bbe3f67SBaptiste Daroussin.Dq a . 439bcf91ad6SBaptiste Daroussin.It Fl l -paginate 4403bbe3f67SBaptiste DaroussinPass the output through 4413bbe3f67SBaptiste Daroussin.Xr pr 1 4423bbe3f67SBaptiste Daroussinto paginate it. 443bcf91ad6SBaptiste Daroussin.It Fl L Ar label Fl -label Ar label 4443bbe3f67SBaptiste DaroussinPrint 4453bbe3f67SBaptiste Daroussin.Ar label 4463bbe3f67SBaptiste Daroussininstead of the first (and second, if this option is specified twice) 4473bbe3f67SBaptiste Daroussinfile name and time in the context or unified diff header. 448bcf91ad6SBaptiste Daroussin.It Fl p -show-c-function 4493bbe3f67SBaptiste DaroussinWith unified and context diffs, show with each change 4503bbe3f67SBaptiste Daroussinthe first 40 characters of the last line before the context beginning 4513bbe3f67SBaptiste Daroussinwith a letter, an underscore or a dollar sign. 4528f79bd9bSTom JonesFor C and Objective-C source code following standard layout conventions, this 4538f79bd9bSTom Joneswill show the prototype of the function the change applies to. 454bcf91ad6SBaptiste Daroussin.It Fl T -initial-tab 4553bbe3f67SBaptiste DaroussinPrint a tab rather than a space before the rest of the line for the 4563bbe3f67SBaptiste Daroussinnormal, context or unified output formats. 4573bbe3f67SBaptiste DaroussinThis makes the alignment of tabs in the line consistent. 458bcf91ad6SBaptiste Daroussin.It Fl t -expand-tabs 4593bbe3f67SBaptiste DaroussinWill expand tabs in output lines. 4603bbe3f67SBaptiste DaroussinNormal or 4613bbe3f67SBaptiste Daroussin.Fl c 4623bbe3f67SBaptiste Daroussinoutput adds character(s) to the front of each line which may screw up 4633bbe3f67SBaptiste Daroussinthe indentation of the original source lines and make the output listing 4643bbe3f67SBaptiste Daroussindifficult to interpret. 4653bbe3f67SBaptiste DaroussinThis option will preserve the original source's indentation. 466bcf91ad6SBaptiste Daroussin.It Fl w -ignore-all-blanks 4673bbe3f67SBaptiste DaroussinIs similar to 468bcf91ad6SBaptiste Daroussin.Fl b -ignore-space-change 4693bbe3f67SBaptiste Daroussinbut causes whitespace (blanks and tabs) to be totally ignored. 4703bbe3f67SBaptiste DaroussinE.g., 4713bbe3f67SBaptiste Daroussin.Dq if (\ \&a == b \&) 4723bbe3f67SBaptiste Daroussinwill compare equal to 4733bbe3f67SBaptiste Daroussin.Dq if(a==b) . 47464793e74SBaptiste Daroussin.It Fl W Ar number Fl -width Ar number 47564793e74SBaptiste DaroussinOutput at most 47664793e74SBaptiste Daroussin.Ar number 47779208b10SBaptiste Daroussincolumns when using side by side format. 47879208b10SBaptiste DaroussinThe default value is 130. 47953de23f4SDag-Erling SmørgravNote that unless 48053de23f4SDag-Erling Smørgrav.It Fl t 48153de23f4SDag-Erling Smørgravwas specified, 48253de23f4SDag-Erling Smørgrav.Nm 48353de23f4SDag-Erling Smørgravwill always align the second column to a tab stop, so values of 48453de23f4SDag-Erling Smørgrav.Fl -width 48553de23f4SDag-Erling Smørgravsmaller than approximately five times the value of 48653de23f4SDag-Erling Smørgrav.Fl -tabsize 48753de23f4SDag-Erling Smørgravmay yield surprising results. 488fddcb7b8SBaptiste Daroussin.It Fl -changed-group-format Ar GFMT 489fddcb7b8SBaptiste DaroussinFormat input groups in the provided 490fddcb7b8SBaptiste Daroussin.Pp 491fddcb7b8SBaptiste Daroussinthe format is a string with special keywords: 492fddcb7b8SBaptiste Daroussin.Bl -tag -width %< 493fddcb7b8SBaptiste Daroussin.It %< 494fddcb7b8SBaptiste Daroussinlines from FILE1 495fddcb7b8SBaptiste Daroussin.It %< 496fddcb7b8SBaptiste Daroussinlines from FILE2 497fddcb7b8SBaptiste Daroussin.El 498bcf91ad6SBaptiste Daroussin.It Fl -ignore-file-name-case 499bcf91ad6SBaptiste Daroussinignore case when comparing file names 500bcf91ad6SBaptiste Daroussin.It Fl -no-ignore-file-name-case 5014185d1f7SPin-Yi Kuodo not ignore case when comparing file names (default) 502bcf91ad6SBaptiste Daroussin.It Fl -normal 503bcf91ad6SBaptiste Daroussindefault diff output 504bcf91ad6SBaptiste Daroussin.It Fl -speed-large-files 505bcf91ad6SBaptiste Daroussinstub option for compatibility with GNU diff 506bcf91ad6SBaptiste Daroussin.It Fl -strip-trailing-cr 507bcf91ad6SBaptiste Daroussinstrip carriage return on input files 50864793e74SBaptiste Daroussin.It Fl -suppress-common-lines 50964793e74SBaptiste DaroussinDo not output common lines when using the side by side format 51064793e74SBaptiste Daroussin.It Fl -tabsize Ar number 511bcf91ad6SBaptiste DaroussinNumber of spaces representing a tab (default 8) 5123bbe3f67SBaptiste Daroussin.El 5133bbe3f67SBaptiste Daroussin.Pp 5143bbe3f67SBaptiste DaroussinDirectory comparison options: 5153bbe3f67SBaptiste Daroussin.Bl -tag -width Ds 516bcf91ad6SBaptiste Daroussin.It Fl N -new-file 5173bbe3f67SBaptiste DaroussinIf a file is found in only one directory, act as if it was found in the 5183bbe3f67SBaptiste Daroussinother directory too but was of zero size. 519bcf91ad6SBaptiste Daroussin.It Fl P -unidirectional-new-file 5203bbe3f67SBaptiste DaroussinIf a file is found only in 5213bbe3f67SBaptiste Daroussin.Ar dir2 , 5223bbe3f67SBaptiste Daroussinact as if it was found in 5233bbe3f67SBaptiste Daroussin.Ar dir1 5243bbe3f67SBaptiste Daroussintoo but was of zero size. 525bcf91ad6SBaptiste Daroussin.It Fl r -recursive 5263bbe3f67SBaptiste DaroussinCauses application of 5273bbe3f67SBaptiste Daroussin.Nm 5283bbe3f67SBaptiste Daroussinrecursively to common subdirectories encountered. 529bcf91ad6SBaptiste Daroussin.It Fl S Ar name Fl -starting-file Ar name 5303bbe3f67SBaptiste DaroussinRe-starts a directory 5313bbe3f67SBaptiste Daroussin.Nm 5323bbe3f67SBaptiste Daroussinin the middle, beginning with file 5333bbe3f67SBaptiste Daroussin.Ar name . 534bcf91ad6SBaptiste Daroussin.It Fl s -report-identical-files 5353bbe3f67SBaptiste DaroussinCauses 5363bbe3f67SBaptiste Daroussin.Nm 5373bbe3f67SBaptiste Daroussinto report files which are the same, which are otherwise not mentioned. 538bcf91ad6SBaptiste Daroussin.It Fl X Ar file Fl -exclude-from Ar file 5393bbe3f67SBaptiste DaroussinExclude files and subdirectories from comparison whose basenames match 5403bbe3f67SBaptiste Daroussinlines in 5413bbe3f67SBaptiste Daroussin.Ar file . 5423bbe3f67SBaptiste DaroussinMultiple 5433bbe3f67SBaptiste Daroussin.Fl X 5443bbe3f67SBaptiste Daroussinoptions may be specified. 545bcf91ad6SBaptiste Daroussin.It Fl x Ar pattern Fl -exclude Ar pattern 5463bbe3f67SBaptiste DaroussinExclude files and subdirectories from comparison whose basenames match 5473bbe3f67SBaptiste Daroussin.Ar pattern . 5483bbe3f67SBaptiste DaroussinPatterns are matched using shell-style globbing via 5493bbe3f67SBaptiste Daroussin.Xr fnmatch 3 . 5503bbe3f67SBaptiste DaroussinMultiple 5513bbe3f67SBaptiste Daroussin.Fl x 5523bbe3f67SBaptiste Daroussinoptions may be specified. 5533bbe3f67SBaptiste Daroussin.El 5543bbe3f67SBaptiste Daroussin.Pp 5553bbe3f67SBaptiste DaroussinIf both arguments are directories, 5563bbe3f67SBaptiste Daroussin.Nm 5573bbe3f67SBaptiste Daroussinsorts the contents of the directories by name, and then runs the 5583bbe3f67SBaptiste Daroussinregular file 5593bbe3f67SBaptiste Daroussin.Nm 5603bbe3f67SBaptiste Daroussinalgorithm, producing a change list, 5613bbe3f67SBaptiste Daroussinon text files which are different. 5623bbe3f67SBaptiste DaroussinBinary files which differ, 5633bbe3f67SBaptiste Daroussincommon subdirectories, and files which appear in only one directory 5643bbe3f67SBaptiste Daroussinare described as such. 5653bbe3f67SBaptiste DaroussinIn directory mode only regular files and directories are compared. 56679208b10SBaptiste DaroussinIf a non-regular file such as a device special file or FIFO is encountered, 56779208b10SBaptiste Daroussina diagnostic message is printed. 5683bbe3f67SBaptiste Daroussin.Pp 5693bbe3f67SBaptiste DaroussinIf only one of 5703bbe3f67SBaptiste Daroussin.Ar file1 5713bbe3f67SBaptiste Daroussinand 5723bbe3f67SBaptiste Daroussin.Ar file2 5733bbe3f67SBaptiste Daroussinis a directory, 5743bbe3f67SBaptiste Daroussin.Nm 5753bbe3f67SBaptiste Daroussinis applied to the non-directory file and the file contained in 5763bbe3f67SBaptiste Daroussinthe directory file with a filename that is the same as the 5773bbe3f67SBaptiste Daroussinlast component of the non-directory file. 5783bbe3f67SBaptiste Daroussin.Pp 5793bbe3f67SBaptiste DaroussinIf either 5803bbe3f67SBaptiste Daroussin.Ar file1 5813bbe3f67SBaptiste Daroussinor 5823bbe3f67SBaptiste Daroussin.Ar file2 5833bbe3f67SBaptiste Daroussinis 5843bbe3f67SBaptiste Daroussin.Sq - , 5853bbe3f67SBaptiste Daroussinthe standard input is 5863bbe3f67SBaptiste Daroussinused in its place. 5873bbe3f67SBaptiste Daroussin.Ss Output Style 5883bbe3f67SBaptiste DaroussinThe default (without 5893bbe3f67SBaptiste Daroussin.Fl e , 5903bbe3f67SBaptiste Daroussin.Fl c , 5913bbe3f67SBaptiste Daroussinor 592bcf91ad6SBaptiste Daroussin.Fl n -rcs 5933bbe3f67SBaptiste Daroussin.\" -C 5943bbe3f67SBaptiste Daroussinoptions) 5953bbe3f67SBaptiste Daroussinoutput contains lines of these forms, where 5963bbe3f67SBaptiste Daroussin.Va XX , YY , ZZ , QQ 5973bbe3f67SBaptiste Daroussinare line numbers respective of file order. 5983bbe3f67SBaptiste Daroussin.Pp 5993bbe3f67SBaptiste Daroussin.Bl -tag -width "XX,YYcZZ,QQ" -compact 6003bbe3f67SBaptiste Daroussin.It Li XX Ns Ic a Ns Li YY 6013bbe3f67SBaptiste DaroussinAt (the end of) line 6023bbe3f67SBaptiste Daroussin.Va XX 6033bbe3f67SBaptiste Daroussinof 6043bbe3f67SBaptiste Daroussin.Ar file1 , 6053bbe3f67SBaptiste Daroussinappend the contents 6063bbe3f67SBaptiste Daroussinof line 6073bbe3f67SBaptiste Daroussin.Va YY 6083bbe3f67SBaptiste Daroussinof 6093bbe3f67SBaptiste Daroussin.Ar file2 6103bbe3f67SBaptiste Daroussinto make them equal. 6113bbe3f67SBaptiste Daroussin.It Li XX Ns Ic a Ns Li YY,ZZ 6123bbe3f67SBaptiste DaroussinSame as above, but append the range of lines, 6133bbe3f67SBaptiste Daroussin.Va YY 6143bbe3f67SBaptiste Daroussinthrough 6153bbe3f67SBaptiste Daroussin.Va ZZ 6163bbe3f67SBaptiste Daroussinof 6173bbe3f67SBaptiste Daroussin.Ar file2 6183bbe3f67SBaptiste Daroussinto line 6193bbe3f67SBaptiste Daroussin.Va XX 6203bbe3f67SBaptiste Daroussinof file1. 6213bbe3f67SBaptiste Daroussin.It Li XX Ns Ic d Ns Li YY 6223bbe3f67SBaptiste DaroussinAt line 6233bbe3f67SBaptiste Daroussin.Va XX 6243bbe3f67SBaptiste Daroussindelete 6253bbe3f67SBaptiste Daroussinthe line. 6263bbe3f67SBaptiste DaroussinThe value 6273bbe3f67SBaptiste Daroussin.Va YY 6283bbe3f67SBaptiste Daroussintells to which line the change would bring 6293bbe3f67SBaptiste Daroussin.Ar file1 6303bbe3f67SBaptiste Daroussinin line with 6313bbe3f67SBaptiste Daroussin.Ar file2 . 6323bbe3f67SBaptiste Daroussin.It Li XX,YY Ns Ic d Ns Li ZZ 6333bbe3f67SBaptiste DaroussinDelete the range of lines 6343bbe3f67SBaptiste Daroussin.Va XX 6353bbe3f67SBaptiste Daroussinthrough 6363bbe3f67SBaptiste Daroussin.Va YY 6373bbe3f67SBaptiste Daroussinin 6383bbe3f67SBaptiste Daroussin.Ar file1 . 6393bbe3f67SBaptiste Daroussin.It Li XX Ns Ic c Ns Li YY 6403bbe3f67SBaptiste DaroussinChange the line 6413bbe3f67SBaptiste Daroussin.Va XX 6423bbe3f67SBaptiste Daroussinin 6433bbe3f67SBaptiste Daroussin.Ar file1 6443bbe3f67SBaptiste Daroussinto the line 6453bbe3f67SBaptiste Daroussin.Va YY 6463bbe3f67SBaptiste Daroussinin 6473bbe3f67SBaptiste Daroussin.Ar file2 . 6483bbe3f67SBaptiste Daroussin.It Li XX,YY Ns Ic c Ns Li ZZ 6493bbe3f67SBaptiste DaroussinReplace the range of specified lines with the line 6503bbe3f67SBaptiste Daroussin.Va ZZ . 6513bbe3f67SBaptiste Daroussin.It Li XX,YY Ns Ic c Ns Li ZZ,QQ 6523bbe3f67SBaptiste DaroussinReplace the range 6533bbe3f67SBaptiste Daroussin.Va XX , Ns Va YY 6543bbe3f67SBaptiste Daroussinfrom 6553bbe3f67SBaptiste Daroussin.Ar file1 6563bbe3f67SBaptiste Daroussinwith the range 6573bbe3f67SBaptiste Daroussin.Va ZZ , Ns Va QQ 6583bbe3f67SBaptiste Daroussinfrom 6593bbe3f67SBaptiste Daroussin.Ar file2 . 6603bbe3f67SBaptiste Daroussin.El 6613bbe3f67SBaptiste Daroussin.Pp 6623bbe3f67SBaptiste DaroussinThese lines resemble 6633bbe3f67SBaptiste Daroussin.Xr ed 1 6643bbe3f67SBaptiste Daroussinsubcommands to convert 6653bbe3f67SBaptiste Daroussin.Ar file1 6663bbe3f67SBaptiste Daroussininto 6673bbe3f67SBaptiste Daroussin.Ar file2 . 6683bbe3f67SBaptiste DaroussinThe line numbers before the action letters pertain to 6693bbe3f67SBaptiste Daroussin.Ar file1 ; 6703bbe3f67SBaptiste Daroussinthose after pertain to 6713bbe3f67SBaptiste Daroussin.Ar file2 . 6723bbe3f67SBaptiste DaroussinThus, by exchanging 6733bbe3f67SBaptiste Daroussin.Ic a 6743bbe3f67SBaptiste Daroussinfor 6753bbe3f67SBaptiste Daroussin.Ic d 6763bbe3f67SBaptiste Daroussinand reading the line in reverse order, one can also 6773bbe3f67SBaptiste Daroussindetermine how to convert 6783bbe3f67SBaptiste Daroussin.Ar file2 6793bbe3f67SBaptiste Daroussininto 6803bbe3f67SBaptiste Daroussin.Ar file1 . 6813bbe3f67SBaptiste DaroussinAs in 6823bbe3f67SBaptiste Daroussin.Xr ed 1 , 6833bbe3f67SBaptiste Daroussinidentical 6843bbe3f67SBaptiste Daroussinpairs (where num1 = num2) are abbreviated as a single 6853bbe3f67SBaptiste Daroussinnumber. 686f38702e5SCameron Katri.Sh ENVIRONMENT 687f38702e5SCameron Katri.Bl -tag -width DIFFCOLORS 688f38702e5SCameron Katri.It Ev DIFFCOLORS 689f38702e5SCameron KatriThe value of this variable is the form 690f38702e5SCameron Katri.Ar add Ns : Ns Ar rm , 691f38702e5SCameron Katriwhere 692f38702e5SCameron Katri.Ar add 693f38702e5SCameron Katriis the ASCII escape sequence for additions and 694f38702e5SCameron Katri.Ar rm 695f38702e5SCameron Katriis the ASCII escape sequence for deletions. 696f38702e5SCameron KatriIf this is unset, 697f38702e5SCameron Katri.Nm 698f38702e5SCameron Katriuses green for additions and red for removals. 699f38702e5SCameron Katri.El 7003bbe3f67SBaptiste Daroussin.Sh FILES 7013bbe3f67SBaptiste Daroussin.Bl -tag -width /tmp/diff.XXXXXXXX -compact 70279208b10SBaptiste Daroussin.It Pa /tmp/diff.XXXXXXXX 7033bbe3f67SBaptiste DaroussinTemporary file used when comparing a device or the standard input. 7043bbe3f67SBaptiste DaroussinNote that the temporary file is unlinked as soon as it is created 7053bbe3f67SBaptiste Daroussinso it will not show up in a directory listing. 7063bbe3f67SBaptiste Daroussin.El 7073bbe3f67SBaptiste Daroussin.Sh EXIT STATUS 7083bbe3f67SBaptiste DaroussinThe 7093bbe3f67SBaptiste Daroussin.Nm 7103bbe3f67SBaptiste Daroussinutility exits with one of the following values: 7113bbe3f67SBaptiste Daroussin.Pp 7123bbe3f67SBaptiste Daroussin.Bl -tag -width Ds -offset indent -compact 7133bbe3f67SBaptiste Daroussin.It 0 7143bbe3f67SBaptiste DaroussinNo differences were found. 7153bbe3f67SBaptiste Daroussin.It 1 7163bbe3f67SBaptiste DaroussinDifferences were found. 7173bbe3f67SBaptiste Daroussin.It >1 7183bbe3f67SBaptiste DaroussinAn error occurred. 7193bbe3f67SBaptiste Daroussin.El 7208cf449dbSTom Jones.Pp 7218cf449dbSTom JonesThe 7228cf449dbSTom Jones.Fl -help 7238cf449dbSTom Jonesand 7248cf449dbSTom Jones.Fl -version 7258cf449dbSTom Jonesoptions exit with a status of 0. 726204fa3b0SFernando Apesteguía.Sh EXAMPLES 727204fa3b0SFernando ApesteguíaCompare 728204fa3b0SFernando Apesteguía.Pa old_dir 729204fa3b0SFernando Apesteguíaand 730204fa3b0SFernando Apesteguía.Pa new_dir 731204fa3b0SFernando Apesteguíarecursively generating an unified diff and treating files found only in one 732204fa3b0SFernando Apesteguíaof those directories as new files: 733204fa3b0SFernando Apesteguía.Bd -literal -offset indent 734204fa3b0SFernando Apesteguía$ diff -ruN /path/to/old_dir /path/to/new_dir 735204fa3b0SFernando Apesteguía.Ed 736204fa3b0SFernando Apesteguía.Pp 737204fa3b0SFernando ApesteguíaSame as above but excluding files matching the expressions 738204fa3b0SFernando Apesteguía.Dq *.h 739204fa3b0SFernando Apesteguíaand 740204fa3b0SFernando Apesteguía.Dq *.c : 741204fa3b0SFernando Apesteguía.Bd -literal -offset indent 742204fa3b0SFernando Apesteguía$ diff -ruN -x '*.h' -x '*.c' /path/to/old_dir /path/to/new_dir 743204fa3b0SFernando Apesteguía.Ed 744204fa3b0SFernando Apesteguía.Pp 745204fa3b0SFernando ApesteguíaShow a single line indicating if the files differ: 746204fa3b0SFernando Apesteguía.Bd -literal -offset indent 747204fa3b0SFernando Apesteguía$ diff -q /boot/loader.conf /boot/defaults/loader.conf 748204fa3b0SFernando ApesteguíaFiles /boot/loader.conf and /boot/defaults/loader.conf differ 749204fa3b0SFernando Apesteguía.Ed 750204fa3b0SFernando Apesteguía.Pp 751204fa3b0SFernando ApesteguíaAssuming a file named 752204fa3b0SFernando Apesteguía.Pa example.txt 753204fa3b0SFernando Apesteguíawith the following contents: 754204fa3b0SFernando Apesteguía.Bd -literal -offset indent 755204fa3b0SFernando ApesteguíaFreeBSD is an operating system 756204fa3b0SFernando ApesteguíaLinux is a kernel 757204fa3b0SFernando ApesteguíaOpenBSD is an operating system 758204fa3b0SFernando Apesteguía.Ed 759204fa3b0SFernando Apesteguía.Pp 760204fa3b0SFernando ApesteguíaCompare stdin with 761204fa3b0SFernando Apesteguía.Pa example.txt 762204fa3b0SFernando Apesteguíaexcluding from the comparison those lines containing either 763204fa3b0SFernando Apesteguía.Qq Linux 764204fa3b0SFernando Apesteguíaor 765204fa3b0SFernando Apesteguía.Qq Open : 766204fa3b0SFernando Apesteguía.Bd -literal -offset indent 767204fa3b0SFernando Apesteguía$ echo "FreeBSD is an operating system" | diff -q -I 'Linux|Open' example.txt - 768204fa3b0SFernando Apesteguía.Ed 7693bbe3f67SBaptiste Daroussin.Sh SEE ALSO 7703bbe3f67SBaptiste Daroussin.Xr cmp 1 , 7713bbe3f67SBaptiste Daroussin.Xr comm 1 , 7723bbe3f67SBaptiste Daroussin.Xr diff3 1 , 7733bbe3f67SBaptiste Daroussin.Xr ed 1 , 7743bbe3f67SBaptiste Daroussin.Xr patch 1 , 775933870f0SBaptiste Daroussin.Xr pr 1 , 7763bbe3f67SBaptiste Daroussin.Xr sdiff 1 7773bbe3f67SBaptiste Daroussin.Rs 7783bbe3f67SBaptiste Daroussin.%A James W. Hunt 7793bbe3f67SBaptiste Daroussin.%A M. Douglas McIlroy 7803bbe3f67SBaptiste Daroussin.%T "An Algorithm for Differential File Comparison" 7813bbe3f67SBaptiste Daroussin.%J Computing Science Technical Report 7823bbe3f67SBaptiste Daroussin.%Q Bell Laboratories 41 7833bbe3f67SBaptiste Daroussin.%D June 1976 7843bbe3f67SBaptiste Daroussin.Re 7853bbe3f67SBaptiste Daroussin.Sh STANDARDS 7863bbe3f67SBaptiste DaroussinThe 7873bbe3f67SBaptiste Daroussin.Nm 7883bbe3f67SBaptiste Daroussinutility is compliant with the 7893bbe3f67SBaptiste Daroussin.St -p1003.1-2008 7903bbe3f67SBaptiste Daroussinspecification. 7913bbe3f67SBaptiste Daroussin.Pp 7923bbe3f67SBaptiste DaroussinThe flags 793*d9a9f23dSDag-Erling Smørgrav.Op Fl AaDdIiLlNnPpqSsTtwXxy 7943bbe3f67SBaptiste Daroussinare extensions to that specification. 7953bbe3f67SBaptiste Daroussin.Sh HISTORY 7963bbe3f67SBaptiste DaroussinA 7973bbe3f67SBaptiste Daroussin.Nm 7983bbe3f67SBaptiste Daroussincommand appeared in 7993bbe3f67SBaptiste Daroussin.At v6 . 80087740ff2SDavid E. O'BrienThe 80187740ff2SDavid E. O'Brien.Nm 8026561c0ecSDag-Erling Smørgravimplementation used in 8036561c0ecSDag-Erling Smørgrav.Fx 8046561c0ecSDag-Erling Smørgravwas GNU diff until 8056561c0ecSDag-Erling Smørgrav.Fx 11.4 . 8066561c0ecSDag-Erling SmørgravThis was replaced in 80787740ff2SDavid E. O'Brien.Fx 12.0 8086561c0ecSDag-Erling Smørgravby a BSD-licensed implementation written by 8096561c0ecSDag-Erling Smørgrav.An Todd Miller . 8106561c0ecSDag-Erling SmørgravSome GNUisms were lost in the process. 811*d9a9f23dSDag-Erling Smørgrav.Pp 812*d9a9f23dSDag-Erling Smørgravlibdiff was imported from the Game of Trees version control system and default 813*d9a9f23dSDag-Erling Smørgravalgorithm was changed to Myers for FreeBSD 15. 814