md5sum: only one argument may be specified when using --check

Posted in Linux/Unix/BSD -

I burn CDs and DVDs for my Linux CD Mall website on a CentOS 4 machine and use md5sum checksums to ensure that the ISO images have downloaded correctly from the http or ftp server or via bittorrent. I store each ISO files's md5sum in a separate .md5 file and use the md5sum command's -c flag to check the contents are valid like so:

md5sum -c SimplyMEPIS-CD_7.0-rel_32.iso.md5

If the file checksums correctly, then the output will look like this:

SimplyMEPIS-CD_7.0-rel_32.iso: OK

In order to check multiple files at once, it would be nice to do this:

md5sum -c *.md5

but the md5sum command in CentOS 4 complains with this error message:

md5sum: only one argument may be specified when using --check
Try `md5sum --help' for more information.

This method of checking multiple files at once does work for more recent versions of the md5sum command but unfortunately does not work for the version shipped with CentOS 4. However, with a little BASH magic it's possible to still issue just one command (instead of manually entering them one after the other after each checksum has completed) like so:

for filename in `ls -1 *.md5`; do md5sum -c $filename; done

Using the Simply Mepis example above, where there is a 32 bit and 64 bit version of the ISO image, the output from the above command would look like this:

SimplyMEPIS-CD_7.0-rel_32.iso: OK
SimplyMEPIS-CD_7.0-rel_64.iso: OK

So not quite as easy as "md5sum -c *.md5", but easier than having to checksum each one of them one by one.

Related posts: