file check

Chris Jack chris_jack at
Tue Jul 15 13:17:41 BST 2008

On Mon, Jul 14, 2008 at 1:16 PM, Christopher Jones  wrote:
> What's the quickest/easiest way to check that two large (~5Gb) files are
> identical?

% time cmp 600Mbfile 600Mbfile_copy

real    0m7.964s
user    0m6.099s
sys     0m1.734s
% echo $?
% time cksum 600Mbfile

2782026514      629145600       z

real    0m6.183s
user    0m4.925s
sys     0m1.161s

You can multiply that last one by 2 to get a fair comparison. cmp is almost twice as fast on my hardware for that file - plus it's 100% reliable.

Basically cksum (and similar) have to do some maths and cmp doesn't (much). You might want to check file sizes are the same first as:

% echo hi>>600Mbfile_copy

% time cmp z z2
cmp: EOF on z

real    0m7.957s
user    0m6.097s
sys     0m1.723s

% echo $?

i.e. As the time is basically the same as for identically sized files, cmp doesn't seem smart enough to check file size first.


PS I went through significant hoops to get this to display with correct CR/LFs so please don't flame if it didn't work

I am doing a 9 day trek through the Sahara on behalf of the mental health charity Sane.
For more details and to support me, go to:

100’s of Nikon cameras to be won with Live Search

More information about the mailing list