Everyone has heard of md5 checksums, that’s almost a given. But I must say that I did not use it except for very large files (iso’s and ilk…) because manually comparing the checksums was very cumbersome to do a lot of times.
Of course that if you have various files, you dump the checksums and files names into another file, and do something like this:
$ md5sum -c filename
where filename must contain one line for each file to check, in the following format:
<checksum value><TWO WHITESPACES><name of file to be checked>
Pay special attention to the fact that separation must be exactly two spaces, anything else will yield the cryptic error message:
no properly formatted MD5 checksum lines found
That said, if all have is one file and checksum to check, you can always do this:
$ echo ‘<checksum value><TWO SPACES><file to check>’ | md5sum -c
Note that the single quotes are necessary because otherwise echo will just put one space, and eliminate the extra space, thus making md5sum fail.
As an endnote, I found the two spaces thing by trying (and it not working) and with the help of Google. Unbelievably, in the md5sum manpage, while it says that you can put checksum and file name in a file as shown above, it gives no mention of the two spaces detail! I eventually found it to be the culprit of my successive failed attempts, and that’s the reason for writing this post: so you don’t have to waste as much time as I did.
The exact same technique (two spaces included) works for SHA1 checksums, just replace (in Linux) ‘md5sum’ with ‘sha1sum’:
$ echo ‘<checksum value><TWO SPACES><file to check>’ | sha1sum -c