1DIFF(1)                            GNU Tools                           DIFF(1)
2
3
4

NAME

6       diff - find differences between two files
7

SYNOPSIS

9       diff [options] from-file to-file
10

DESCRIPTION

12       In the simplest case, diff compares the contents of the two files from-
13       file and to-file.  A file name of - stands for text read from the stan‐
14       dard  input.   As  a special case, diff - - compares a copy of standard
15       input to itself.
16
17       If from-file is a directory and to-file is not, diff compares the  file
18       in  from-file  whose file name is that of to-file, and vice versa.  The
19       non-directory file must not be -.
20
21       If both from-file and to-file are  directories,  diff  compares  corre‐
22       sponding files in both directories, in alphabetical order; this compar‐
23       ison is not recursive unless the -r or  --recursive  option  is  given.
24       diff  never compares the actual contents of a directory as if it were a
25       file.  The file that is fully specified  may  not  be  standard  input,
26       because  standard  input  is nameless and the notion of ``file with the
27       same name'' does not apply.
28
29       diff options begin with -, so normally from-file and  to-file  may  not
30       begin  with -.  However, -- as an argument by itself treats the remain‐
31       ing arguments as file names even if they begin with -.
32
33   Options
34       Below is a summary of all of the options that GNU diff  accepts.   Most
35       options have two equivalent names, one of which is a single letter pre‐
36       ceded by -, and the other of which is a long name preceded by --.  Mul‐
37       tiple  single letter options (unless they take an argument) can be com‐
38       bined into a single command line word: -ac  is  equivalent  to  -a  -c.
39       Long  named  options  can  be abbreviated to any unique prefix of their
40       name.  Brackets ([ and ]) indicate that an  option  takes  an  optional
41       argument.
42
43       -lines Show  lines (an integer) lines of context.  This option does not
44              specify an output format by itself; it has no effect  unless  it
45              is combined with -c or -u.  This option is obsolete.  For proper
46              operation, patch typically needs at least two lines of context.
47
48       -a     Treat all files as text and compare them line-by-line,  even  if
49              they do not seem to be text.
50
51       -b     Ignore changes in amount of white space.
52
53       -B     Ignore changes that just insert or delete blank lines.
54
55       --brief
56              Report  only  whether  the  files differ, not the details of the
57              differences.
58
59       -c     Use the context output format.
60
61       -C lines
62       --context[=lines]
63              Use the context output format, showing lines (an integer)  lines
64              of  context,  or three if lines is not given.  For proper opera‐
65              tion, patch typically needs at least two lines of context.
66
67       --changed-group-format=format
68              Use format to output a line  group  containing  differing  lines
69              from both files in if-then-else format.
70
71       -d     Change  the  algorithm to perhaps find a smaller set of changes.
72              This makes diff slower (sometimes much slower).
73
74       -D name
75              Make merged if-then-else format output, conditional on the  pre‐
76              processor macro name.
77
78       -e
79       --ed   Make output that is a valid ed script.
80
81       --exclude=pattern
82              When  comparing  directories,  ignore  files  and subdirectories
83              whose basenames match pattern.
84
85       --exclude-from=file
86              When comparing  directories,  ignore  files  and  subdirectories
87              whose basenames match any pattern contained in file.
88
89       --expand-tabs
90              Expand  tabs  to spaces in the output, to preserve the alignment
91              of tabs in the input files.
92
93       -f     Make output that looks vaguely like an ed script but has changes
94              in the order they appear in the file.
95
96       -F regexp
97              In  context  and  unified  format, for each hunk of differences,
98              show some of the last preceding line that matches regexp.
99
100       --forward-ed
101              Make output that looks vaguely like an ed script but has changes
102              in the order they appear in the file.
103
104       -h     This option currently has no effect; it is present for Unix com‐
105              patibility.
106
107       -H     Use heuristics to speed handling of large files that have numer‐
108              ous scattered small changes.
109
110       --horizon-lines=lines
111              Do not discard the last lines lines of the common prefix and the
112              first lines lines of the common suffix.
113
114       -i     Ignore changes in case; consider upper- and  lower-case  letters
115              equivalent.
116
117       -I regexp
118              Ignore  changes that just insert or delete lines that match reg‐
119              exp.
120
121       --ifdef=name
122              Make merged if-then-else format output, conditional on the  pre‐
123              processor macro name.
124
125       --ignore-all-space
126              Ignore white space when comparing lines.
127
128       --ignore-blank-lines
129              Ignore changes that just insert or delete blank lines.
130
131       --ignore-case
132              Ignore changes in case; consider upper- and lower-case to be the
133              same.
134
135       --ignore-matching-lines=regexp
136              Ignore changes that just insert or delete lines that match  reg‐
137              exp.
138
139       --ignore-space-change
140              Ignore changes in amount of white space.
141
142       --initial-tab
143              Output  a  tab  rather than a space before the text of a line in
144              normal or context format.  This causes the alignment of tabs  in
145              the line to look normal.
146
147       -l     Pass the output through pr to paginate it.
148
149       -L label
150       --label=label
151              Use  label  instead  of  the file name in the context format and
152              unified format headers.
153
154       --left-column
155              Print only the left column of two common lines in side  by  side
156              format.
157
158       --line-format=format
159              Use format to output all input lines in in-then-else format.
160
161       --minimal
162              Change  the  algorithm to perhaps find a smaller set of changes.
163              This makes diff slower (sometimes much slower).
164
165       -n     Output RCS-format diffs; like -f except that each command speci‐
166              fies the number of lines affected.
167
168       -N
169       --new-file
170              In  directory  comparison, if a file is found in only one direc‐
171              tory, treat it as present but empty in the other directory.
172
173       --new-group-format=format
174              Use format to output a group of lines taken from just the second
175              file in if-then-else format.
176
177       --new-line-format=format
178              Use  format  to output a line taken from just the second file in
179              if-then-else format.
180
181       --old-group-format=format
182              Use format to output a group of lines taken from just the  first
183              file in if-then-else format.
184
185       --old-line-format=format
186              Use  format  to  output a line taken from just the first file in
187              if-then-else format.
188
189       -p     Show which C function each change is in.
190
191       -P     When comparing directories, if a file appears only in the second
192              directory  of  the  two,  treat  it  as present but empty in the
193              other.
194
195       --paginate
196              Pass the output through pr to paginate it.
197
198       -q     Report only whether the files differ, not  the  details  of  the
199              differences.
200
201       -r     When  comparing directories, recursively compare any subdirecto‐
202              ries found.
203
204       --rcs  Output RCS-format diffs; like -f except that each command speci‐
205              fies the number of lines affected.
206
207       --recursive
208              When  comparing directories, recursively compare any subdirecto‐
209              ries found.
210
211       --report-identical-files
212       -s     Report when two files are the same.
213
214       -S file
215              When comparing directories, start with the file file.   This  is
216              used for resuming an aborted comparison.
217
218       --from-file=file
219              Compare file to all operands.  file can be a directory.
220
221       --to-file=file
222              Compare all operands to file. file can be a directory.
223
224       --sdiff-merge-assist
225              Print  extra  information to help sdiff.  sdiff uses this option
226              when it runs diff.  This option is not intended for users to use
227              directly.
228
229       --show-c-function
230              Show which C function each change is in.
231
232       --show-function-line=regexp
233              In  context  and  unified  format, for each hunk of differences,
234              show some of the last preceding line that matches regexp.
235
236       --side-by-side
237              Use the side by side output format.
238
239       --speed-large-files
240              Use heuristics to speed handling of large files that have numer‐
241              ous scattered small changes.
242
243       --starting-file=file
244              When  comparing  directories, start with the file file.  This is
245              used for resuming an aborted comparison.
246
247       --suppress-common-lines
248              Do not print common lines in side by side format.
249
250       -t     Expand tabs to spaces in the output, to preserve  the  alignment
251              of tabs in the input files.
252
253       -T     Output  a  tab  rather than a space before the text of a line in
254              normal or context format.  This causes the alignment of tabs  in
255              the line to look normal.
256
257       --text Treat  all  files as text and compare them line-by-line, even if
258              they do not appear to be text.
259
260       -u     Use the unified output format.
261
262       --unchanged-group-format=format
263              Use format to output a group of common  lines  taken  from  both
264              files in if-then-else format.
265
266       --unchanged-line-format=format
267              Use format to output a line common to both files in if-then-else
268              format.
269
270       --unidirectional-new-file
271              When comparing directories, if a file appears only in the second
272              directory  of  the  two,  treat  it  as present but empty in the
273              other.
274
275       -U lines
276       --unified[=lines]
277              Use the unified output format, showing lines (an integer)  lines
278              of  context,  or three if lines is not given.  For proper opera‐
279              tion, patch typically needs at least two lines of context.
280
281       -v
282       --version
283              Output the version number of diff.
284
285       -w     Ignore white space when comparing lines.
286
287       -W columns
288       --width=columns
289              Use an output width of columns in side by side format.
290
291       -x pattern
292              When comparing  directories,  ignore  files  and  subdirectories
293              whose basenames match pattern.
294
295       -X file
296              When  comparing  directories,  ignore  files  and subdirectories
297              whose basenames match any pattern contained in file.
298
299       -y     Use the side by side output format.
300

SEE ALSO

302       cmp(1), comm(1), diff3(1), ed(1), patch(1), pr(1), sdiff(1).
303

DIAGNOSTICS

305       An exit status of 0 means no differences were found, 1 means some  dif‐
306       ferences were found, and 2 means trouble.
307
308
309
310GNU Tools                          22sep1993                           DIFF(1)
Impressum