I have two identically sized files and I need to do a binary diff to check whether they're the same.
I'm currently runnnig diff file1.img file2.img but it's taking quite a while to process my 4GB files. Is this the most efficient way to do this?
|
|
|
|
|||
|
|
|
One of the most common ways of determining if two files are identical (assuming their sizes match) is using a program to create a "hash" (essentially a fingerprint) of a file. The most common ones are For example:
If you have many files that you need to check, for example if you are transferring a directory full of files from one system to another, you can redirect the output from the original system to a file, then
|
|||||||||
|
|
Found a solution - the cmp tool which comes with most Linux flavours. |
|||
|
|
|
If I just want to know if they are the same, I prefer to use sha1sum if it's available, or md5 as a fallback. If I want to know how different they are, or where they're different, one thing that works is to crank them both through 'od' ('octal dump', which usually has a hex option) to make temp files and then diff those. |
|||
|
|