I think I figured this out and it's just a typo, at least when I cut and paste your commands above! You download SHASUMS256.txt
but test against a file called SHASUM256.txt
(missing the S
). Because you throw away the output and pipe it to grep, you weren't seeing that error.
$ sha256sum -c SHASUM256.txt
sha256sum: SHASUM256.txt: No such file or directory
$ sha256sum -c SHASUM256.txt 2>&1|grep -qs OK
$ echo $?
1
Doing an echo $?
tells you the return code of the last command executed (in this case 1
). By correcting the file, it works for me now:
$ sha256sum -c SHASUMS256.txt 2>&1|grep -qs OK
$ echo $?
0