I am trying to validate a file using the following command:

$ md5sum myfile_v2.1.ova -c myfile_v2.1.md5 
md5sum: myfile_v2.1.ova: no properly formatted MD5 checksum lines found
myfile_v2.1.ova: OK

The exit status code seems to be 1

$ echo $?

However when reading the help for the md5sum command, strict mode (which fails upon formatting issues`) should be explicitly enabled;

$ md5sum --help | grep -- --strict
      --strict         exit non-zero for improperly formatted checksum lines

Why on top of all that I get an OK about the file?

  • Does the file have a trailing newline? – muru Jul 2 '18 at 9:25
  • how can I check this? – pkaramol Jul 2 '18 at 9:27
  • Run od -c on the md5 file and see if the last character is a \n – muru Jul 2 '18 at 9:29
  • yep, it is a \n – pkaramol Jul 2 '18 at 9:30

The correct way to verify checksums in an MD5 checksum file is

$ md5sum -c file.md5

In your case:

$ md5sum -c myfile_v2.1.md5

This will read the pathname and checksums in the MD5 file and check them against the corresponding files on disk.

Your command line:

md5sum myfile_v2.1.ova -c myfile_v2.1.md5 

This is equivalent of

md5sum -c myfile_v2.1.ova myfile_v2.1.md5

(due to the way some GNU utilities move command line options to the start of the argument list). This means "check the signatures found in these two MD5 checksum files". Since the first file isn't an MD5 checksum file, it complains.

Also note that it correctly verifies one checksum from the MD5 file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.