Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On Ubuntu 14.04, sha256sum from coreutils works as I expected:

echo 879dd0d7637876be4796f7e6f194a111d21088be85cfe717fc97e2e7f05e79d2 /tmp/myfile | sha256sum -c
/tmp/myfile: OK

However, the exact same command with the exact same file on Debian Wheezy fails:

sha256sum: standard input: no properly formatted SHA256 checksum lines found

I don't understand this. How can I verify the checksum reliably in a shell script on Debian?

On Ubuntu 14.04:

⟫ sha256sum --version
sha256sum (GNU coreutils) 8.21

On Wheezy:

$ sha256sum --version
sha256sum (GNU coreutils) 8.13

manpages on both OSs say:

       sha256sum [OPTION]... [FILE]...

       Print or check SHA256 (256-bit) checksums.  With no FILE,
       or when FILE is -, read standard input.


       -c, --check
              read SHA256 sums from the FILEs and check them
share|improve this question
up vote 26 down vote accepted

It cares about the spacing. If you run:

sha256sum /dev/null

you get

e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  /dev/null

(two spaces). When you use echo like that, there's only one space between the words.

Version 8.13 wants the exact format its output is in. If you use:

echo "$SUM  $FILE" | sha256sum -c

(again, two spaces) it should work. Newer versions don't care about how many spaces there are, so it will work with them too.

share|improve this answer
Added trivia: The second space character has in fact a meaning. It denotes that the checksum has been calculated in text mode. In contrast, a * in front of the filename denotes binary mode. Compare the output of sha256sum -t /dev/null (text mode, the default) with sha256sum -b /dev/null (binary mode). This doesn't make a difference on Unix/Linux, apparently, but it could on Windows. – Dubu Jun 30 '14 at 14:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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