file check

Chris Jack chris_jack at msn.com
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 $?
0
% 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 $?
1

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.

Chris

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: www.justgiving.com/chrisjack
--------------------------------------------------------------------------------

_________________________________________________________________
100’s of Nikon cameras to be won with Live Search
http://clk.atdmt.com/UKM/go/101719808/direct/01/


More information about the london.pm mailing list