Context:
I have a large terabyte drive with various types of large media files, ISO image files, etc. I would like to verify its contents using md5sum
on the first megabyte due to speed/performance.
You can create a sum like this:
FILE=four_gig_file.iso
SUM=$(head -c 1M "$FILE" | md5sum)
printf "%s *%s\n" ${SUM%-} "$FILE" >>test.md5
How would you verify this as the first megabyte's signature is different than the whole file's?
I've seen this done in other languages, but I am wondering
how to do it in Bash. I've experimented with various md5sum -c
permutations involving pipes and whatnot.
Instead of using md5sum -c
, would you have to recompute the hashes into a new file, then 'diff' them?
You can use a
find /directory/path/ -type f -print0 | xargs -0 md5sum blah blah
to work on a large number of files.
PS: Rsync is not an option
UPDATE 2: So as it stands --
Using head, find, and md5sum; one could then create a file from the source directory fairly quickly, then check it with diff on the other side after computing on the destination. Are there clever one-liners or scripts for this?