Checking md5sum for a file
I have two files hello.txt
andhello.txt.md5
MD5 output is in lower format
cat hello.txt.md5
b1946ac92492d2347c6235b4d2611184
I wrote a simple script to check md5sum.
csum=$(cat hello.txt.md5)
echo "$csum hello.txt" | md5sum -c
This script works fine with Ubuntu 13.10
but it throws below error in Ubuntu 12.04
.
md5sum: standard input: no properly formatted MD5 checksum strings found
Can anyone show me how to do this in Ubuntu12.04.
At least my md5sum files have two spaces between the checksum and the filename. Tested your script and it didn't work, added space between $ csum and hello.txt and it did.
This may be due to some change between versions md5sum
.
Running md5sum <file1> <file2>
on both versions should give you an example of what format each version expects.
Specifically, the md5sum
man page says:
The default mode is to print a line with a checksum, character type ('*' for binary, '' for text) and a name for each file.
So, to check for text mode, two spaces usually have to be present (indeed, checking with help md5sum -t t.txt
confirms this). I guess the new version has raised this requirement.
Indeed, here's a GNU coreutils link called "md5sum: Handle BSD Reverse Format Checksums" from 2011-09-16. It makes md5sum
guessing between the two formats.
End was released incoreutils 8.14
, whereas Ubuntu 12.04 is using8.13
.