Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • It should be noted that 'md5sum --check sumfile' does not read from stdin but reads from the files specified in the file 'sumfile'. This means the 'cat file |' part of the command 'cat file | md5sum --check sumfile' does nothing useful. In this specific case the result will be the same but if you change 'file' to another filename this will be ignored and this command may print '-: OK' even when the files differ. Commented Jul 6, 2021 at 12:37
  • 1
    @OFE I have to disagree, please test it yourself in the shell... cat file | is needed in order to work. If cat is omitted md5sum will wait for input on stdin. Also if the file changed md5sum will print -: FAILED. Commented Jul 7, 2021 at 12:48
  • 1
    You are correct, it would seem that the behaviour of md5sum depends on how sumfile was created. It seems my sumfile was created with something like md5sum file > sumfile. This means the sumfile contains the filename which is what causes md5sum --check sumfile to ignore the stdin and read from the file specified in sumfile. cat file | md5sum > sumfile causes the sumfile to contain a - character in place of the filename which is what causes md5sum --check sumfile to read from stdin. My apologies for not doing my homework before commenting. Commented Jul 8, 2021 at 13:47