I am confused how md5sum --check is supposed to work:

$ man md5sum
-c, --check
    read MD5 sums from the FILEs and check them

I have a file, I can pipe it to md5sum:

$ cat file | md5sum
44693b9ef883e231cd9f90f737acd58f  -

When I want to check the integrity of the file tomorrow, how can I check if the md5sum is still 44693b9ef883e231cd9f90f737acd58f?


cat file might be a stream. So I want to use the pipe as in my example, not md5sum file.


You do this:

cat file | md5sum > sumfile

And the next day you can do this:

cat file | md5sum --check sumfile

Which prints:

-: OK

if everything is alright.


I assume that you do know the md5sum of the file.

Just issue the following command:

echo ff19e3f8bde936457b8e53c825110987 myfile | md5sum --check -
myfile: OK

md5sum --check, like md5sum with any other option (or none) takes input from stdin if no file (or -) is specified on the command line.


The default syntax for md5sum is:

$ md5sum file 
068a9a19124df814e52ff5461598cfe4  file

To create a checksum file, redirect standard output to a file:

$ md5sum file > md5.checksum

To verify the file against the checksum file:

$ cd path/to/file
$ md5sum --check path/to/md5.checksum
file: OK

That said, m13r's implementations is equally valid.

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.