-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtdiff.1
865 lines (865 loc) · 26.3 KB
/
tdiff.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
.\" tdiff - tree diffs
.\" tdiff.1 - Manual page
.\" Copyright (C) 2019, 2024 Philippe Troin <[email protected]>
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 3 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
.TH TDIFF 1 "January 2024" "tdiff 0.8.7" "User Commands"
.SH NAME
tdiff \- tree diff, list differences between various inode attributes (
.BR stat(2)
structure) and contents for two directory trees
.SH SYNOPSIS
.B tdiff
[\fI\,OPTIONS\/\fR]... \fIDIRECTORY1\fR \fIDIRECTORY2\fR
.SH DESCRIPTION
.PP
List differences between
.I DIRECTORY1
and
.I DIRECTORY2
file trees, comparing any of the inode attributes, also known as
.BR stat(2)
structure members. Inode attributes are:
.RS 3
.IP \(bu 3
file type (regular file, directory, FIFO, socket, etc.),
.IP \(bu
file size,
.IP \(bu
file block count (physical storage size),
.IP \(bu
owner uid and gid,
.IP \(bu
access, modification and inode change times,
.IP \(bu
the set of hard links a file has,
.IP \(bu
extended attributes (if supported),
.IP \(bu
ACLs (if supported),
.IP \(bu
file system flags (BSD UFS, MacOSX).
.RS -3
.PP
By default,
.B tdiff
reports differences in any file contents or attributes except for the
various file times. The set of attributes to be checked can be
modified with the various options.
.PP
Beyond inode attribute checks,
.B tdiff
can check (and will check by default) regular files for contents
difference. Optionally,
.B tdiff
can use an external program to determine if the files are considered
to be different. See the \fB\-x\fR/\fB\-\-exec\fR,
\fB\-w\fR/\fB\-\-exec\-always\fR, and \fB\-W\fR/\fB\-\-exec\-always\-diff\fR
options.
.SH OPTIONS
.SS Standard Options
.TP
\fB\-h\fR, \fB\-\-help\fR
Show a short \fBh\fRelp message and exit.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Increase \fBv\fRerbosity. Four
cumulative levels of logging verbosity are supported:
.RS 10
.TP
.B -v
report overall statistics: total number of files scanned, compared,
etc.
.TP
.B -vv
report if any files are skipped, and for what reason (exclusion,
already compared, etc.)
.TP
.B -vvv
report internal data structure statistics.
.TP
.B -vvvv
report memory statistics (if available on your system).
.RS -10
.TP
\fB\-V\fR, \fB\-\-version\fR
Show the
.B tdiff
\fBv\fRersion information, compiled-in features and flags (if any)
then exit.
.br
The compiled-in feature list shows which features
.B tdiff
has been compiled with: O_NOATIME, flags, acl, and xattr support,
acl optimization (\fBacl_cmp\fR), the
.BR readdir(2)
implementation used, the file system time granularity (either
seconds (\fI\,s\/\fR) or nanoseconds (\fI\,ns\/\fR)) and if comparing
symbolic links will update their access time (\fBreadlink=readlink\fR)
or not (\fBreadlink=open(O_PATH|O_NOFOLLOW)+readlinkat\fR).
.br
If flags support is compiled in, the list of recognized flags will be
listed as well.
.SS Toggle Options
The single-letter toggle options come in two versions, upper-case and
lower-case. The lower-case option enables the the attribute check,
while the upper-case option disables it.
.PP
The long toggle options are named after the
.BR stat(2)
structure names: for example,
.B \-\-mtime
is used to check the
.I st_mtime
.BR stat(2)
structure member, which is the file modification time. Similarly to
short toggle options, long toggle options have a \fB\-\-no\-\fR
version to turn off the equivalent check (eg. \fB\-\-no\-mtime\fR).
.TP
\fB\-b\fR, \fB\-\-blocks\fR
Report file \fBb\fRlock count differences (\fI\,st_blocks\/\fR) except
for directories which are ignored.
.br
This is on by default.
.TP
\fB\-B\fR, \fB\-\-no\-blocks\fR
Do not report file \fBb\fRlock count differences.
.TP
\fB\-c\fR, \fB\-\-contents\fR
Report file \fBc\fRontent differences for regular files and symbolic
links.
.br
For regular files, their contents are compared and any discrepancies
are reported as a contents difference.
.br
For symbolic links, a difference will be reported if their targets
differ.
.br
See the
.B CONTENTS COMPARISONS
section below for the exact semantics.
.br
This is on by default.
.TP
\fB\-C\fR, \fB\-\-no\-contents\fR
Do not report file \fBc\fRontent differences.
.TP
\fB\-d\fR, \fB\-\-dirs\fR
Diff \fBd\fRirectory contents: report if any file is present in only
one directory.
.br
This is on by default.
.TP
\fB\-D\fR, \fB\-\-no\-dirs\fR
Do not diff \fBd\fRirectory contents: files only present in a single
directory are not reported.
.TP
\fB\-e\fR, \fB\-\-hardlinks\fR
Report any differences in the set of hard links a file may be linked
to.
.br
For example if in a directory two files are hard linked together while
in the other directory, they are not,
.B tdiff
will report that the files are hard links only in the first directory.
.br
.B tdiff
will only report the differences once per set of hard links: if in a
directory \fBf1\fR, \fBf2\fR and \fBf3\fR are hard links while in the
other \fBf1\fR and \fBf2\fR are hard links while \fBf3\fR exists but
is not a hard link,
.B tdiff
will report that \fBf1\fR is only linked to \fBf3\fR in the first
directory but will not report the same information for \fBf2\fR
because \fBf1\fR and \fBf2\fR are part of the same set of hard linked
files.
.br
This is on by default.
.TP
\fB\-E\fR, \fB\-\-no\-hardlinks\fR
Will not report any differences in hard links sets.
.TP
\fB\-f\fR, \fB\-\-flags\fR
Diff file system \fBf\fRlags, as found in the
.BR stat(2)
.I st_flags
structure member. This is only supported on BSD, MacOSX and other
systems that have \fIst_flags\/\fR.
.br
.B tdiff --version
will list which file system flags
.B tdiff
has been compiled with, but
.B tdiff
will report even differences in other flags unknown at compilation
time, but will do so numerically instead of listing the actual flag
name.
.br
This is on by default if your system's
.BR stat(2)
structure has \fIst_flags\fR.
.TP
\fB\-F\fR, \fB\-\-no\-flags\fR
Do not diff file system \fBf\fRlags.
.TP
\fB\-g\fR, \fB\-\-gid\fR
Report on any differences in file \fBg\fRroup ownership (owner group
id, \fIst_gid\/\fR).
.br
This is on by default.
.TP
\fB\-G\fR, \fB\-\-no\-gid\fR
Do not report any differences in file \fBg\fRroup ownership (owner group id).
.TP
\fB\-i\fR, \fB\-\-mtime\fR
Report on any differences in file modification t\fBi\fRme
(\fI\,st_mtime\/\fR), up to nanosecond resolution if the underlying OS
reports it.
.TP
\fB\-I\fR, \fB\-\-no\-mtime\fR
Do not report any differences in file modification t\fBi\fRmes
(\fI\,st_mtime\/\fR).
.br
This is on by default.
.TP
\fB\-j\fR, \fB\-\-major\fR
For device files (either block or character), report any differences
in ma\fBj\fRor device numbers.
.br
Note that major numbers will only be compared if both device files are
of the same type (block or character).
.br
This is on by default.
.TP
\fB\-J\fR, \fB\-\-no\-major\fR
Do not report any differences in ma\fBj\fRor device numbers on device files.
.TP
\fB\-k\fR, \fB\-\-minor\fR
For device files (either block or character), report any differences
in minor device numbers.
.br
Note that minor numbers will only be compared if both device files are
of the same type (block or character).
.br
This is on by default.
.TP
\fB\-K\fR, \fB\-\-no\-minor\fR
Do not report any differences in minor device numbers on device files.
.TP
\fB\-l\fR, \fB\-\-acl\fR
Report on any differences in file AC\fBL\fRs as defined by
.BR acl_set_file(3) .
.br
Any missing or different ACLs between the file pairs are
reported. Access, default and mask ACL entries are supported.
.br
This is on by default if ACLs are supported by the system.
.TP
\fB\-L\fR, \fB\-\-no\-acl\fR
Do not report any differences in file AC\fBL\fRs.
.TP
\fB\-m\fR, \fB\-\-mode\fR
Report on any differences in file access \fBm\fRode (permission bits as
set by
.BR chmod(1) ).
If set,
\fB\-o\fR/\fB\-\-mode\-or\fR and \fB\-a\fR/\fB\-\-mode\-and\fR
bitmasks are applied, if set.
.br
This is on by default.
.TP
\fB\-M\fR, \fB\-\-no\-mode\fR
Do not report any differences in file access \fBm\fRodes (permission
bits).
.TP
\fB\-n\fR, \fB\-\-nlink\fR
Report on any differences in file (hard) link counts
(\fI\,st_\/\fBn\fI\,links\/\fR).
.br
This is on by default.
.TP
\fB\-N\fR, \fB\-\-no\-nlink\fR
Do not report any differences in file (hard) link counts.
.TP
\fB\-q\fR, \fB\-\-xattr\fR
Report on any differences in file extended attributes as defined by
.BR setxattr(2) .
.br
Any missing or different extended attribute between the file pairs is
reported.
.br
This is on by default if extended attributes are supported by the system.
.TP
\fB\-Q\fR, \fB\-\-no\-xattr\fR
Do not report any differences in file extended attributes.
.TP
\fB\-s\fR, \fB\-\-size\fR
Report file \fBs\fRize differences (\fI\,st_size\/\fR), except for
directories which are ignored.
.br
This is on by default.
.TP
\fB\-S\fR, \fB\-\-no\-size\fR
Do not report file \fBs\fRize differences.
.TP
\fB\-t\fR, \fB\-\-type\fR
Report file \fBt\fRype differences (files, directories, symbolic links,
etc.)
.br
This is on by default.
.TP
\fB\-T\fR, \fB\-\-no\-type\fR
Do not report file \fBt\fRype differences between the two compared
directories.
.TP
\fB\-u\fR, \fB\-\-uid\fR
Report on any differences in file \fBu\fRser ownership (owner user id,
\fIst_uid\/\fR).
.br
This is on by default.
.TP
\fB\-U\fR, \fB\-\-no\-uid\fR
Do not report any differences in file \fBu\fRser ownership (owner user
id).
.TP
\fB\-y\fR, \fB\-\-atime\fR
Report on any differences in file access time (\fI\,st_atime\/\fR), up
to nanosecond resolution if the underlying OS reports it.
.br
Since merely reading a file causes the access time to be updated, this
option is likely to be of limited use.
.B tdiff
will not update the file access times when comparing files if compiled
on an OS with
.B O_NOATIME
.BR open(2)
support, whenever possible. One of the Operating Systems with
.B O_NOATIME
support, Linux, only allows to open a file with
.B O_NOATIME
if
.B tdiff
is ran by the file owner or root. All files for which this is the
case will then be opened with \fBNO_ATIME\fR, but
.B tdiff
will silently drop the
.B O_NOATIME
flag if a
.I Permission denied
error is encountered. Please also note that commands specified with
\fB\-x\fR/\fB\-\-exec\fR, \fB\-w\fR/\fB\-\-exec\-always\fR or
\fB\-W\fR/\fB\-\-exec\-always\-diff\fR may update the access times of
the files they read.
.TP
\fB\-Y\fR, \fB\-\-no\-atime\fR
Do not report any differences in file access times
(\fI\,st_atime\/\fR).
.br
This is on by default.
.TP
\fB\-z\fR, \fB\-\-ctime\fR
Report on any differences in file inode change time
(\fI\,st_ctime\/\fR), up to nanosecond resolution if the underlying OS
reports it.
.br
Since inode change times are automatically set by Unix to the current
time and cannot be changed afterwards, they will always be reported as
different for any two file trees, except in rare cases (likely
involving cloning raw file system images).
.TP
\fB\-Z\fR, \fB\-\-no\-ctime\fR
Do not report any differences in file file inode change times
(\fI\,st_ctime\/\fR).
.br
This is on by default.
.SS Preset Options
The preset single letter options are either a numeric preset level
from \fI0\fR to \fI9\/\fR, or
.B \-p
followed by a preset name or level. Presets can also be activated
with the
.B \-\-preset
long option followed by either a numeric preset level or a preset
name.
.br
Preset names can be shortened to their smallest unambiguous prefix.
For example, \fB\-\-preset\fR \fIamtimes\/\fR can be shortened to
\fIam\/\fR, \fImissing\fR to \fImiss\/\fR, \fIdefault\fR to \fId\/\fR,
etc.
.PP
The presets are cumulative, preset level \fI9\fR is a super-set of
preset level \fI8\/\fR, itself a super-set of level \fI7\fR and so on.
.PP
The default preset level when
.B tdiff
starts parsing its options is preset
\fI6\/\fR/\fI\,notimes\/\fR/\fI\,default\/\fR.
.TP
\fB\-0\fR, \fB\-p\fR|\fB\-\-preset\fR \fI0\/\fR|\fI\,none\fR
Do not check anything. All the toggles are set to their inactive
(\fB\-\-no\-\fR) state.
.br
If only this preset is active (it is provided last on the command line
for example),
.B tdiff
will not report anything but will still traverse the file trees. This
is only useful to reset \fBtdiff\fR's set of comparisons to the empty
set and add exactly which fields should be compared with further
toggle options.
.TP
\fB\-1\fR, \fB\-p\fR|\fB\-\-preset\fR \fI1\/\fR|\fI\,missing\/\fR|\fI\,type\fR
Report missing files and different file types.
.br
.B tdiff
will only emit messages for either files missing in either directory
(\fB\-d\fR/\fB\-\-dirs\fR) or if they are of different file types
(\fB\-t\fR/\fB\-\-type\fR). All the other toggles are set to their
inactive (\fB\-\-no\-\fR) state.
.TP
\fB\-2\fR, \fB\-p\fR|\fB\-\-preset\fR \fI2\/\fR|\fI\,mode\fR
In addition to the comparisons enabled at preset level \fI1\/\fR,
.B tdiff
will also enable file mode comparisons (\fB\-m\fR/\fB\-\-mode\fR). All
the other toggles are set to their inactive (\fB\-\-no\-\fR) state.
.TP
\fB\-3\fR, \fB\-p\fR|\fB\-\-preset\fR \fI3\/\fR|\fI\,owner\fR
In addition to the comparisons enabled at preset level \fI2\/\fR,
.B tdiff
will also enable user id (\fB\-u\fR/\fB\-\-uid\fR), group id
(\fB\-g\fR/\fB\-\-gid\fR) and, if supported, Access Control Lists
(\fB\-l\fR/\fB\-\-acl\fR) comparisons. All
the other toggles are set to their inactive (\fB\-\-no\-\fR) state.
.TP
\fB\-4\fR, \fB\-p\fR|\fB\-\-preset\fR \fI4\/\fR|\fI\,hardlinks\fR
In addition to the comparisons enabled at preset level \fI3\/\fR,
.B tdiff
will also enable link count (\fB\-n\fR/\fB\-\-nlink\fR) and hard link
targets (\fB\-e\fR/\fB\-\-hardlinks\fR) comparisons. All
the other toggles are set to their inactive (\fB\-\-no\-\fR) state.
.TP
\fB\-5\fR, \fB\-p\fR|\fB\-\-preset\fR \fI5\/\fR|\fI\,contents\fR
In addition to the comparisons enabled at preset level \fI4\/\fR,
.B tdiff
will also compare file contents (\fB\-c\fR/\fB\-\-contents\fR), size
(\fB\-s\fR/\fB\-\-size\fR), block usage (\fB\-b\fR/\fB\-\-blocks\fR),
and for device files, major (\fB\-j\fR/\fB\-\-major\fR) and minor
(\fB\-k\fR/\fB\-\-minor\fR) device numbers. All
the other toggles are set to their inactive (\fB\-\-no\-\fR) state.
.TP
\fB\-6\fR, \fB\-p\fR|\fB\-\-preset\fR \fI6\/\fR|\fI\,notimes\/\fR|\fI\,default\fR
In addition to the comparisons enabled at preset level \fI5\/\fR,
.B tdiff
will also compare, if supported, flags (\fB\-f\fR/\fB\-\-flags\fR) and
extended attributes (\fB\-q\fR/\fB\-\-xattr\fR). All the other toggles
are set to their inactive (\fB\-\-no\-\fR) state. This corresponds to
a state where all toggles are on except the three times
(\fB\-y\fR/\fB\-\-atime\fR, \fB\-i\fR/\fB\-\-mtime\fR and
\fB\-z\fR/\fB\-\-ctime\fR) that are off.
.br
If your system does not support either flags or extended attributes,
then preset level \fI6\fR is equivalent to preset level \fI5\/\fR.
.br
This is the default preset level.
.TP
\fB\-7\fR, \fB\-p\fR|\fB\-\-preset\fR \fI7\/\fR|\fI\,mtime\fR
In addition to the comparisons enabled at preset level \fI6\/\fR,
.B tdiff
will also compare file modification times
(\fB\-i\fR/\fB\-\-mtime\fR). This corresponds to a state where all
toggles are on except the file access time (\fB\-y\fR/\fB\-\-atime\fR)
and the inode modification time (\fB\-z\fR/\fB\-\-ctime\fR) that are
off.
.TP
\fB\-8\fR, \fB\-p\fR|\fB\-\-preset\fR \fI8\/\fR|\fI\,amtimes\fR
In addition to the comparisons enabled at preset level \fI7\/\fR,
.B tdiff
will also compare file access times (\fB\-y\fR/\fB\-\-atime\fR). This
corresponds to a state where all toggles are on except the inode
modification time (\fB\-z\fR/\fB\-\-ctime\fR) that is off.
.TP
\fB\-9\fR, \fB\-p\fR|\fB\-\-preset\fR \fI9\/\fR|\fI\,alltimes\fR|\fI\,all\fR
.B tdiff
will compare all available attributes, turning all toggles on.
.SS Other Miscellaneous Options
.TP
\fB\-a\fR, \fB\-\-mode\-and\fR \fIMASK\fR
When comparing file permission bits, perform a binary \fBa\fRnd
between the permission bits and
.I MASK
before comparing them.
.br
.I MASK
is specified in octal, like with
.BR chmod(2) ,
unless prefixed with \fI0x\/\fR, in which case it is parsed as
hexadecimal.
.TP
\fB\-o\fR, \fB\-\-mode\-or\fR \fIMASK\fR
When comparing file permission bits, perform a binary \fBo\fRr between
the permission bits and
.I MASK
before comparing them.
.br
.I MASK
is specified in octal, like with
.BR chmod(2) ,
unless prefixed with \fI0x\/\fR, in which case it is parsed as hexadecimal.
.TP
\fB\-w\fR, \fB\-\-exec\-always\fR \fICOMMAND... \\\/;\fR
Always execute
.I COMMAND
for any pair of matching regular files found in the trees. Refer to the
.B CONTENTS COMPARISONS
section for details.
.br
If either options are specified more than once, the last command defined
will be used.
.br
Using either option turns on the \fB-c\fR/\fB--contents\fR toggle.
.TP
\fB\-W\fR, \fB\-\-exec\-always\-diff\fR
Always execute
.I diff \-u
for any pair of matching regular files found in the trees.
This is a shortcut for:
.in +2
.br
.B tdiff \-\-exec\-always diff \-u %1 %2 \\\\;
.in -2
.br
The option will supersede whichever command was specified in a
\fB\-w\fR/\fB\-\-exec\-always\fR option appearing earlier on the option
list.
.br
Using either option turns on the \fB-c\fR/\fB--contents\fR toggle.
.TP
\fB\-x\fR, \fB\-\-exec\fR \fICOMMAND... \\\/;\fR
Uses
.I COMMAND
when comparing files whose sizes are the same. Refer to the
.B CONTENTS COMPARISONS
section for details.
.br
If either options are specified more than once, the last command defined
will be used.
.br
Using either option turns on the \fB-c\fR/\fB--contents\fR toggle.
.TP
\fB\-X\fR, \fB\-\-exclude\fR \fIFILE\fR
Excludes
.I FILE
from processing: any discrepancies on a file or missing file named
.I FILE
will not be reported. Neither will external commands be ran on them.
If
.I FILE
matches the name of a directory, it will not be descended into and any
sub-directories or files it contains will be completely ignored.
.br
This option may be specified more than once, all the files listed will
be added to the exclusion list.
.TP
\fB\-O\fR, \fB\-\-follow\-symlinks\fR
Completely ignore symbolic links and always f\fBO\fRllow and dereference them.
.br
This is off by default (symbolic links are not followed / dereferenced).
.SH HARD LINKS
.B tdiff
optimizes for hard links in two ways:
.RS 3
.IP \(bu 3
.B tdiff
will skip examining a pair of files if it has already compared the
pair's hard links copies.
.RS 3
.PP
For example, if you have \fIfile1\fR hard linked to \fIfile2\fR in
both \fIDIRECTORY1\fR and \fIDIRECTORY2\/\fR,
.B tdiff
will only report any differences for \fIfile1\fR and will skip
\fIfile2\fR entirely since it's linked to \fIfile1\fR in both examined
directories, and the list of differences would the same as for the
already reported \fIfile1\fR case.
.RS -3
.IP \(bu 3
.B tdiff
will skip examining two hard-linked files.
.RS 3
.PP
For example, if \fIdir1/file\fR is hard linked to \fIdir2/file\/\fR,
then
.B tdiff
will omit examining the file pair entirely since they really are the
same object and would have no differences at all.
.RS -6
.PP
\fBtdiff\fR's hard link optimization depends on files' inode and
device numbers to be stable, unique and consistent at least for the
duration of the
.B tdiff
run. This is generally the case for traditional
file systems.
.PP
.B tdiff
can optionally show which hard linked files are skipped and for what
reason when run at the verbosity level 2 or above (\fB-vv\fR or
\fB--verbose --verbose\fR).
.SH CONTENTS COMPARISONS
.B tdiff
uses built-in code for file contents comparisons. It avoid running an actual
comparison if the file's sizes (\fI\,st_size\/\fR) are different: the
files with different sizes will be reported as having different
contents without even comparing them as the size difference is enough
to ascertain that their contents differ.
.PP
Optionally,
.B tdiff
can run external commands to perform the comparison. When providing
an external command, the
.I COMMAND
must be passed as multiple arguments terminated by a semi-colon, which
must be escaped to avoid processing by the shell.
.I COMMAND
should not be quoted as a single argument.
.br
In the arguments can appear the strings
.I %1
and
.I %2
which will be respectively replaced by the paths to files in the first
and second compared directories.
.I %1
and
.I %2
can only appear once on the command line, and must be full words:
they cannot appear inside a larger shell word.
.br
For example:
.RS 2
.br
.B tdiff --exec gtkdiff %1 %2 \\\\; directory1 directory2
.RS -2
.PP
If either the \fB\-x\fR or \fB\-\-exec\fR options are used, the
command specified there will be ran instead of the built-in comparison
and its exit status used to detect a difference (zero exit status
meaning no difference, and non-zero meaning a difference). With
either these options in effect,
.B tdiff
will not print any error message if the files are different, the
command used for \fB\-x\fR/\fB\-\-exec\fR should take care of
reporting the error. Note that the command
.I will not be ran if
.B tdiff
.I can find via the file size
that the files differ by virtue of having different sizes.
.PP
If either the \fB\-w\fR/\fB\-\-exec\-always\fR or
\fB\-W\fR/\fB\-\-exec\-always\-diff\fR options are used, the command
specified with these options will always be ran for every pair of
regular files having the same path in both directories, whether or not
they have the same size. The internal comparison pass will run and
will report if the files are different, then the
\fB\-w\fR/\fB\-\-exec\-always\fR/\fB\-W\fR/\fB\-\-exec\-always\-diff\fR
command will run.
.B tdiff
will record a difference if the
\fB\-w\fR/\fB\-\-exec\-always\fR/\fB\-W\fR/\fB\-\-exec\-always\-diff\fR
command returns with non\-zero exit status, even if the internal
comparison or the \fB\-x\fR/\fB\-\-exec\fR command are successful.
.PP
If both \fB\-x\fR/\fB\-\-exec\fR and
\fB\-w\fR/\fB\-\-exec\-always\fR/\fB\-W\fR/\fB\-\-exec\-always\-diff\fR
options are used, then the command specified for
\fB\-x\fR/\fB\-\-exec\fR will be ran if the file sizes of the compared
files are the same, and the command specified by
\fB\-w\fR/\fB\-\-exec\-always\fR/\fB\-W\fR/\fB\-\-exec\-always\-diff\fR
will always run.
.br
This means that with options from both groups active, both the
\fB\-x\fR/\fB\-\-exec\fR and
\fB\-w\fR/\fB\-\-exec\-always\fR/\fB\-W\fR/\fB\-\-exec\-always\-diff\fR
commands will be ran for files with the same size.
.SH EXIT STATUS
.B tdiff
exits with status:
.TP
0
if no discrepancies nor errors were encountered.
.TP
1
if there were any problems with arguments or parsing the command line.
.TP
2
if there were any differences reported, either by
.B tdiff
logging a discrepancy, or any of the \fB\-x\fR/\fB\-\-exec\fR or
\fB\-w\fR/\fB\-\-exec\-always\fR commands exiting with non-zero
status.
.TP
3
if there was any system error (a file couldn't be read for example).
.TP
4
if there was an internal error. This should not happen.
.SH EXAMPLES
Check that the two file trees rooted at
.I directory1
and
.I directory2
are exactly the same, including symbolic link targets if any,
permissions, hard disk block usage, owner user and group ids, and if
supported, flags, ACLs and extended attributes:
.RS 4
.PP
.B tdiff
.I directory1 directory2
.RS -4
.PP
Same as previous example, but also check that the file modification
times are the same:
.RS 4
.PP
.B tdiff -i
.I directory1 directory2
.RS -4
.PP
Only report if any files are present in only one directory:
.RS 4
.PP
.B tdiff \-0 \-\-dirs
.I directory1 directory2
.RS -4
.PP
Report only ownership (user or group id) differences, ignore any
missing files:
.RS 4
.PP
.B tdiff \-0 \-\-uid \-\-gid
.I directory1 directory2
.RS -4
.PP
Report only group permission bits differences, ignore any missing files:
.RS 4
.PP
.B tdiff \-0 \-\-mode \-\-mode\-and 70
.I directory1 directory2
.RS -2
.PP
or:
.RS 2
.PP
.B tdiff \-0 \-\-mode \-\-mode\-or 7707
.I directory1 directory2
.RS -4
.PP
Report only sticky bits differences, ignore any missing files:
.RS 4
.PP
.B tdiff \-0 \-\-mode \-\-mode\-and 1000
.I directory1 directory2
.RS -2
.PP
or:
.RS 2
.PP
.B tdiff \-0 \-\-mode \-\-mode\-or 6777
.I directory1 directory2
.RS -4
.PP
Run
.B cmp \-l
on every file of the same size in both trees:
.RS 4
.PP
.B tdiff \-0 \-\-exec cmp -l %1 %2 \\\\\/;
.I directory1 directory2
.RS -4
.PP
Run super-diff: diff files with
.B diff \-u
and reports any other kind of differences in inode contents except for
times:
.RS 4
.PP
.B tdiff \-\-exec\-always\-diff
.I directory1 directory2
.RS -2
.PP
or more tersely:
.RS 2
.PP
.B tdiff \-W
.I directory1 directory2
.RS -4
.PP
Same with file modification times:
.RS 4
.PP
.B tdiff \-W \-\-preset mtime
.I directory1 directory2
.RS -2
.PP
or also:
.RS 2
.PP
.B tdiff \-Wi
.I directory1 directory2
.RS -4
.SH REPORTING BUGS
Report bugs on the
.UR https://github.com/F-i-f/tdiff/issues
GitHub Issues page
.UE .
.SH COPYRIGHT
Copyright (C) 1999, 2008, 2014, 2019, 2024 Philippe Troin (
.UR https://github.com/F-i-f
F-i-f on GitHub
.UE ).
.PP
.B tdiff
comes with ABSOLUTELY NO WARRANTY.
.br
This is free software, and you are welcome to redistribute it
under certain conditions.
.br
You should have received a copy of the GNU General Public License
along with this program. If not, see
.UR http://www.gnu.org/licenses/
.UE .
.SH SEE ALSO
.BR acl_set_file(1) ,
.BR chmod(1) ,
.BR diff(1) ,
.BR getfacl(1) ,
.BR getfattr(1) ,
.BR open(2) ,
.BR setxattr(2) ,
.BR stat(2) .
\" LocalWords: tdiff Troin phil MERCHANTABILITY inode fI fR fB dirs
\" LocalWords: DIRECTORY1 DIRECTORY2 fBtdiff fBd fRirectory TP fBh
\" LocalWords: fRelp fBm fRode bitmasks fRodes fBt fRype fBv br acl
\" LocalWords: fRerbosity fRersion nlink xattr fBb dtmfugsbcnejkql
\" LocalWords: ctime mtime atime fRlock fIst fBc DTMFUGZIRSBCNEJKQL
\" LocalWords: inodes fRontent fBg fRroup fBi fRme fRmes fBj fRor
\" LocalWords: ACLs fBn fIlinks fBo setxattr NOATIME fBs fBu fRser
\" LocalWords: fRize getfacl getfattr fICOMMAND fIFILE fIMASK chmod
\" LocalWords: directory1 directory2 fIDIRECTORY2 cmp IP uid fIdir1
\" LocalWords: fIDIRECTORY1 gid UFS MacOSX vv vvv vvvv fI0x UE fR's
\" LocalWords: fIfile1 fIfile2 fIdir2 files' readdir eg hardlinks
\" LocalWords: fBf1 fBf2 fBf3 fIamtimes fIam fImissing fImiss fId
\" LocalWords: fBf fRlags fIdefault fI9 fI8 fI7 fI6 notimes fI0 fI1
\" LocalWords: fI2 fI3 fI4 fI5 amtimes alltimes Wi ns fBa fRnd fRr
\" LocalWords: fBL fRs gtkdiff fBNO symlinks fBO fRllow dereference
\" LocalWords: dereferenced readlink NOFOLLOW readlinkat