Depending on if you want only this tool, the full set of PNU tools, or PNU plus a selection of additional third-parties tools, use one of these commands:
pip install pnu-dcmp
pip install PNU
pip install pytnix
dcmp - compare two directories, deduplicating if needed
dcmp [--dedup] [-h|--nosymlinks] [-s|--silent|--quiet] [-v|--verbose] [--debug] [--help|-?] [--version] [--] directory1 directory2
The dcmp utility compares two directories contents and writes the results to the standard output. By default, dcmp is silent if the directories are the same; if they differ, the differences are reported with a leading:
- '!' if files contents are different
- '+' if the file or directory appears in directory1 but not in directory2
- '-' if the file or directory appears in directory2 but not in directory1
- '=' if the files contents are identical and you used the -v|--verbose option
If you use the -s|--silent|--quiet option, differences won't be reported and the overall result will be returned though the exit status (thus stopping the comparison at the first difference).
By default, dcmp follows symbolic links to directories, unless you tell it not to do so with the -h|--nosymlinks option, or you use the --dedup option for deduplicating the first directory, removing identical files (ie. those having the same SHA-256 message digest) and symbolic links, as well as empty directories sitting there.
The following options are available:
Options | Use |
---|---|
--dedup | In dir1, remove empty dirs and files which are identical to those in dir2 |
-h|--nosymlinks | Do not follow symbolic links |
-s|--silent|--quiet | Print nothing for differing dirs; return exit status only |
-v|--verbose | Print identical dirs and files names |
--debug | Enable debug mode |
--help|-? | Print usage and a short help message and exit |
--version | Print version and exit |
-- | Options processing terminator |
The DCMP_DEBUG environment variable can also be set to any value to enable debug mode.
The dcmp utility exits with one of the following values:
- 0: The directories are identical
- 1: The directories are different
- >1: An error occurred
The dcmp utility is not a standard UNIX command.
This implementation tries to follow the PEP 8 style guide for Python code.
To be tested under Windows.
This implementation was made for the PNU project.
The dcmp utility was made to help spot potential differences between restored backups and current files and directories.
It is available under the 3-clause BSD license.