Compare files inode attributes
Compare two file trees, showing any differences in their:
- file size,
- file block count (physical storage size),
- owner user and group ids (uid & gid),
- access, modification and inode change times,
- hard link count, and sets of hard linked files,
- extended attributes (if supported),
- ACLs (if supported),
- file system flags (BSD UFS, MacOSX).
tdiff comes with an extensive manual page.
Check that the two file trees rooted at directory1 and directory2 are exactly the same, including symbolic link targets if any, permissions, hard disk block usage, owner user or group ids, and if supported, flags, ACLs and extended attributes:
tdiff directory1 directory2
Same as previous example, but also check that the file modification times are the same:
tdiff -i directory1 directory2
Only report if any files are present in only one directory:
tdiff -0 --dirs directory1 directory2
Report only ownership (user or group id) differences, ignore any missing files:
tdiff -0 --uid --gid directory1 directory2
Report only group permission bits differences, ignore any missing files:
tdiff -0 --mode --mode-and 70 directory1 directory2
tdiff -0 --mode --mode-or 7707 directory1 directory2
Report only sticky bits differences, ignore any missing files:
tdiff -0 --mode --mode-and 1000 directory1 directory2
tdiff -0 --mode --mode-or 6777 directory1 directory2
cmp -l on every file of the same size in both trees:
tdiff -0 --exec cmp -l %1 %2 \; directory1 directory2
Run super-diff: diff files with diff -u and reports any other kind of differences in inode contents except for times:
tdiff --exec-always-diff directory1 directory2
or more tersely:
tdiff -W directory1 directory2
Same with file modification times:
tdiff -W --preset mtime directory1 directory2
tdiff -Wi directory1 directory2
tdiff 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/].
Building from source
C Compiler (eg. gcc)
Make (eg. GNU make)
libacl, optionally, for ACL support, if needed on your system.
autotools (autoconf, automake) is only required if building from the repository.
groff is optionally needed to generate the man page hard copies (HTML & PDF). It is only needed if you intend to update the manual page ROFF source.
From a release
When downloading from the GitHub release pages, be careful to download the source code from the link named with the full file name (tdiff-0.8.5.tar.gz), and not from the links marked Source code (zip) or Source code (tar.gz) as these are repository snapshots generated automatically by GitHub and require specialized tools to build (see Building from GitHub).
After downloading the sources, unpack and build with:
tar xvzf tdiff-0.8.5.tar.gz cd tdiff-0.8.5 ./configure make make check make install make install-pdf install-html # Optional
Alternately, you can create a RPM file by moving the source tar file
and the included
tdiff.spec in your rpm build directory and running:
rpmbuild -ba SPECS/tdiff.spec
From the GitHub repository
Clone the repository:
git clone https://github.com/F-i-f/tdiff.git cd tdiff autoreconf -i ./configure make make check make install make install-pdf install-html # Optional
November 1, 2019.
- Minor bug fixes terminal width handling.
- Improvements in .spec cross-distribution compatibility.
June 14, 2019.
- A new -O/--follow-symlinks option has been implemented.
- Minor bug fixes in zsh completion.
May 22, 2019.
Fix rare file descriptor leak on directory enumeration failure.
Fix other inconsequential Coverity-detected errors.
May 12, 2019.
- Fix missing xattr feature on Android.
- Provide a build script for building all Android targets.
May 7, 2019.
- tdiff could fail on Linux with O_NOATIME support when comparing files or reading directories not owned by the invoking user, when not running as root.
- Specify better tdiff's behavior with regards to O_NOATIME.
- Spec file now BuildRequires fakeroot.
- Enhanced test suite / regressions.
- Don't abort() on unexpected state, exit cleanly.
- Fix nanosecond resolution detection in regressions.
May 3, 2019.
- The -e/--hardlinks option has been implemented: tdiff can now compare hard link sets between both directories and report which hard links are only in one of the directories.
Some options have been renamed for consistency with the stat(2) structure member names, and others to avoid non-standard options.
Old option (before 0.8) New option (0.8 and later) Notes -r/-R -y/-Y atime check -o/-O/--owner/--no-owner -u/-U/--uid/--no-uid file user id --group/--no-group --gid/--no-gid file group id --nlinks --nlink hard link count -a/--all -6/--preset default default option state -A/--no-all -0/--preset none clear all comparison toggles -| -o file mode OR bit mask -& -a file mode AND bit mask
A lot of presets have been added, replacing the -a/--all and -A/--no-all options. They can be used numerically (-3) or by name (-p owner/--preset owner)
tdiff --version now reports the stat time granularity (seconds or microseconds).
A message is printed when a comparison is skipped or sub-trees are pruned because they cannot be read.
The README and NEWS files are now installed in
HTML and PDF versions of the manual page can optionally be installed by running
Fix compilation error on systems supporting st_xtimespec stat structure members.
tdiff's exit status was not always consistent with the documented behavior, this is now fixed.
Fix crash with the -x/--exec or -w/--exec-always command lines do not end with a semicolon.
- Manual page improvements and updates.
- Test suite (
make check) improvements.
- Zsh completion function improvements.
- Lots of changes under the hood.
April 30, 2019.
- Fix crash when an unreadable directory is encountered.
- Fix regression failures on odd systems.
- Fix display overflow in --version.
April 27, 2019.
- Fixed rare bug where files could be skipped (and misreported as having no differences) if two files with the name inode number but with different device numbers were scanned within the second argument's sub-tree.
April 26, 2019.
Bash and Zsh completion functions are now included.
A manual page is now included.
New -W --always-exec-diff option.
The (unimplemented) option -e / --hardlinks has been (temporarily) removed.
When reporting mode discrepancies (-m / --mode), if no mask is used with --mode-or or --mode-and, then masked values are not shown.
The -| / --mode-or and -& / --mode-and options now take their arguments as octal (no need to lead them with a zero to force octal parsing).
The -p / --no-mmap option has been removed.
Using the -v / --verbose option more than once now increases the logging level.
The -V / --version option now prints compiled in features (ACLs, xattrs, etc.)
The command specified in -w / --exec-always is not run anymore if both files to be compared are hard-links of each other.
Updated BSD / MacOSX flags.
Fixed bug where paths could be wrongly displayed (when one of the arguments was / or ../ for example).
Change the inode cache hash function to DJB2 (performance).
Times could sometimes be compared incorrectly.
Compare symbolic links contents only when requested.
Crash fixed when the command line for -x / --exec or -w / --exec-always did not reference both %1 and %2.
Move to Git, git-aware build scripts.
Open files with O_NOATIME.
Factorize some autoconf code into macros.
Fix build errors when cross-compiling.
Support getdents64 on Linux.
Portability fixes for FreeBSD 12, MacOSX, Android, Solaris.
Add test suite.
Include RPM spec file.
January 31, 2014.
First public release.
Now includes support for ACLs, extended attributes, and link count.
tdiff was written by Philippe Troin (F-i-f on GitHub).