I have two folders which I want to open with the same application. To me, both folders seem identical, but to the application, they don’t.
First, I used this command to find any differences in the contents of the folders:
find folder/ -type f -name * -exec md5 {} + | awk '{print $1}' | sort | md5
This command yields the same result for both folders. But then, I tried this command:
tar c folder/ | md5
This command yields different output for both folders. The command also takes longer to complete for one folder than for the other.
I’m using Mac OS X Snow Leopard. What is going on here?
tar cincludes the folder name in it’s compression, so unless the folders have the same exact name that will cause a mismatch.Also remember that
tarwill try to recover the permissions used on files compressed, that might also cause a mismatch if the folders don’t have the same exact permissions, as well as ownership.To see if permissions/ownership is the same for the two folders use something as the below, piped to
sort | md5or whatever.The above will have the folder name "foobar" in the output, you should strip that out, you could use something like this:
My recommendation
If you just want to see if the contents of files and their corresponding file name matches, use the
diffutility instead of your own custom written version, as below:Documentation of
diffdiff