file check

Aaron Crane perl at aaroncrane.co.uk
Tue Jul 15 13:42:00 BST 2008


Chris Jack writes:
> cmp doesn't seem smart enough to check file size first.

cmp's default mode of operation involves emitting a description of the
first difference -- either a byte/line position or an "EOF on $file"
message.  That can't be done without examining the whole of both
files, even if they're of different sizes.

But the -s option will switch cmp into a mode where it reports
equality using nothing but its exit status; at that point, cmp (or at
least the version I've just tried with, from GNU diffutils 2.8.1) will
return instantly if the files are of different sizes.

-- 
Aaron Crane ** http://aaroncrane.co.uk/


More information about the london.pm mailing list