Yes, asterisk *
is required for this command. Take a look at this example.
This is the binary file, and let say the correct md5sum value is exampleofcorrectmd5value00000000
(32 hexadecimal char)
[root@Linux update]# ls -lh
total 137M
-rw-r--r-- 1 root root 137M Nov 5 13:01 binary-file.run.tgz
[root@Linux update]#
-c, --check
read MD5 sums from the FILEs and check them
If the md5sum value match with the binary file, you'll get this output
[root@Linux ~]# md5sum -c <<< "exampleofcorrectmd5value00000000" *binary-file.run.tgz"
binary-file.run.tgz: OK
[root@Linux ~]#
And this is when the md5sum value doesn't match
[root@Linux update]# md5sum -c <<< "exampleofwrongmd5value0000000000 *binary-file.run.tgz"
binary-file.run.tgz: FAILED
md5sum: WARNING: 1 of 1 computed checksum did NOT match
[root@Linux update]#
Without asterisk *
, you'll get the following error message even thought the md5 value is correct
[root@Linux ~]# md5sum -c <<< "exampleofcorrectmd5value00000000 binary-file.run.tgz"
md5sum: standard input: no properly formatted MD5 checksum lines found
[root@Linux ~]#
Also, you'll get the same error message if md5sum doesn't have 32 hexadecimal characters in it. In this example, it only has 31 characters.
[root@Linux ~]# md5sum -c <<< "exampleofmd5valuelessthan32char *binary-file.run.tgz"
md5sum: standard input: no properly formatted MD5 checksum lines found
[root@Linux ~]#
Solution for many files
If you have many files and want to automate the process, you can follow these steps:
user@Ubuntu:~$ ls -lh
total 12K
-rw-rw-r-- 1 user user 4 Nov 5 14:54 file-a
-rw-rw-r-- 1 user user 4 Nov 5 14:54 file-b
-rw-rw-r-- 1 user user 4 Nov 5 14:54 file-c
user@Ubuntu:~$
Generate md5sum for each files and save it to md5sum.txt
user@Ubuntu:~$ md5sum * | tee md5sum.txt
0bee89b07a24ae27c83fc3d5951213c1 file-a
1b2297c171a9a450d184871ccf6c9ad4 file-b
7f4d13d9b0b6ac086fd68637067435c5 file-c
user@Ubuntu:~$
To check md5sum for all files, use the following command.
user@Ubuntu:~$ md5sum -c md5sum.txt
file-a: OK
file-b: OK
file-c: OK
user@Ubuntu:~$
This is example if the md5sum value doesn't match with the file. In this case, I'm going to modify file-b
content
user@Ubuntu:~$ echo "new data" > file-b
user@Ubuntu:~$
See, this is the error message. Hope this helps.
user@Ubuntu:~$ md5sum -c md5sum.txt
file-a: OK
file-b: FAILED
file-c: OK
md5sum: WARNING: 1 computed checksum did NOT match
user@Ubuntu:~$