Manpage of COMPDIR
Section: Misc. Reference Manual Pages (1L)
Updated: 16 November 1988
compdir - compare two directories
recursively compares the files in the two directories
By default, it compares the contents of the files
and prints nothing if they compare equal; else it prints
is a directory under one path but not under the other path;
is newer under the printed
than under the other directory;
exists in one path only.
is about the same speed as
which compares modification times instead of contents, is
much faster than
- Compare all files, including files beginning with a dot (.).
The default action is to ignore such files.
- Summarize the options and exit.
to be line buffered.
- Compare modification times instead of contents. This is much faster
than comparing the contents.
It's useful if you expect the directories' files to have the same
dates, such as would be the case if you created a copy using
- When both files are the same, print lines like
Normally only non-matches are printed.
- Compare contents of files, and if they are the same
touch the modification time on the newer file to have the same time
as the older file. This is useful
if you have created a backup directory but didn't preserve dates.
In that case, you can do
compdir -t dir1 dir2
once, and thereafter you can more quickly compare the directories by
looking at file modification times instead of the file contents.
- Print both filenames, instead of just the newer, when files differ or
when both are the same, but just the one filename for ``only'' files.
- Print both filenames, instead of just the newer, for all compared files.
This makes it easy to edit the output into shell commands that, say,
copy the newer file to the older. The only or newer file is printed first;
the missing or older filename is printed second.
- Exclude patterns. Any file in
dir1 that matches the sh(1)-style
wildcard pattern specified by
is ignored in comparisons. More than one pattern may be given; it's
often necessary to quote the pattern to prevent interpretation by
the shell. Note: slashes (/) are treated as ordinary characters when
The following command
compares the contents of the files in
ignoring object files and libraries.
% compdir -X "*.o" "*.a" mydir mydir.backup