0

This question already has an answer here:

Runing

echo "zyc.txt" | openssl dgst -sha512

(stdin)= 11aa472bf4c97ffb1fae06a3f7175127da084c5dfb840038ee308b37136330e5b6a56cc053c62881f10aec88948d8addb1d4844496cdb08e4067b4fd4601330e

or

echo "zyc.txt" | sha512sum 11aa472bf4c97ffb1fae06a3f7175127da084c5dfb840038ee308b37136330e5b6a56cc053c62881f10aec88948d8addb1d4844496cdb08e4067b4fd4601330e

Output is wrong, hash should be

DDD2379F9A1ADF4F0AFA0BEFAFDB070FB942D4D4E0331A31D43494149307221E5E699DA2A08F59144B0ED415DEA6F920CF3DAB8CA0B740D874564D83B9B6F815

Here is info on my computer

Linux MobileSpace 4.14.0-3-amd64 #1 SMP Debian 4.14.17-1 (2018-02-14) x86_64 GNU/Linux

sha512sum --version
sha512sum (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Ulrich Drepper, Scott Miller, and David Madore.

Is this a bug or am I doing it wrong?

marked as duplicate by Jeff Schaller, Stephen Kitt debian Feb 27 '18 at 5:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

Echo appends a newline, which you may suppress with -n:

echo -n "zyc.txt" | sha512sum 
ddd2379f9a1adf4f0afa0befafdb070fb942d4d4e0331a31d43494149307221e5e699da2a08f59144b0ed415dea6f920cf3dab8ca0b740d874564d83b9b6f815  -

Most of the time, you enjoy the newline, so your prompt is on the start of the next line, not in the middle of the last output line.

You have to keep that in mind when doing wc, too:

echo -n "zyc.txt" | wc
      0       1       7
echo "zyc.txt" | wc
      1       1       8

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