in reply to Re^2: Finding out whether two directories are the same
in thread Finding out whether two directories are the same

You might take a gander at how rsync for inspiration. Or maybe use rsync -n and see if it thinks there's a difference.

The cake is a lie.
The cake is a lie.
The cake is a lie.

  • Comment on Re^3: Finding out whether two directories are the same

Replies are listed 'Best First'.
Re^4: Finding out whether two directories are the same
by JavaFan (Canon) on Aug 28, 2008 at 13:24 UTC
    Testing for identical content (whether using rsync or something else) will not give you a 100% sure answer. Even if the content is the same, the directories do not have to, for instance:
    $ cp -a dir1 dir2
    will create a second directory with identical content, but dir1 and dir2 are different. You'd have to look at inode change time to see a difference, but even then, it's not a garantee.

    OTOH, even if you think the content is different, the directories may be the same. If the directories are the same, you'll be looking at the same directory twice, but since you cannot garantee you'll be looking twice at the same time, the directory, or any of its files inside it, may have changed between your two inspections.

    Having said that, I don't think there's solution that will always work anywhere. But usually you will know a bit of the environment. If you know your filesystems are local, and no device is mounted twice, checking inode and device number will do. If you know the directories to be tested aren't being modified while you make your check, checking for content may work.

Re^4: Finding out whether two directories are the same
by rovf (Priest) on Aug 28, 2008 at 13:11 UTC

    As far I see, rsync does not run on native Windows (Cygwin is not an option here) :-(

    -- 
    Ronald Fischer <ynnor@mm.st>