C
Case
What is a good (readable) way of comparing two
files. I just need to know if they match, or not.
Thanks,
Case
files. I just need to know if they match, or not.
Thanks,
Case
What is a good (readable) way of comparing two
files. I just need to know if they match, or not.
What is a good (readable) way of comparing two files. I
just need to know if they match, or not.
What is a good (readable) way of comparing two
files. I just need to know if they match, or not.
Case said:What is a good (readable) way of comparing two
files. I just need to know if they match, or not.
Michele said:If with "if they match" you mean "if they are _exactly_ the same",
then I'd just take a cheksum (e.g. MD5) of both and compare them.
Martin Kissner said:Case wrote :
since seem to be on Linux, you might use "diff"
diff file1 file2
diff -y file1 file2
if you want to use the side by side output format.
Chad said:use File::Compare;
Is probably better for what you want.
'cmp' is better, if all you want to know is whether they differ or
not, and not present the differences. We don't know whether they are
text files.
But what Case means by "readable", I don't know.
Martin Kissner said:Arndt Jonasson wrote :
Neither do I.
I don't even know if he wants to diff two files in the shell or by a
Perlscript
In the shell, however, you could use 'diff -q' if you only want to know
if the files differ. I don't know if 'cmp' or 'diff' is better.
Since an MD5 checksum is often shorter than the file it is taken of (it
would be pointless to use if it weren't), the statement "two files are
exactly the same iff the MD5 checksums are equal" is wrong. After all,
You're perfectly right. Re-reading what I wrote I realize that it
seems to suggest that equality of MD5 sums is a necessary condition
for equality of files, which indeed is _not_ the case[*]. I apologize
to the OP for the inexactness of my claim.
Oh, but it *is* a *necessary* condition. What it isn't is a *sufficient*
condition. You're the first person I've seen who's reversed the sense of
those particular terms, though confusing the underlying logical
propositions is extremely common and leads to some nasty fallacies
(affirming the consequent and denying the antecedent).
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.