I want to find the md5 hash of the string "a", but running echo "a" | md5sum gives me another hash than what I get if I search the internet (for example using DuckDuckGo or the first search result I found).

Running echo "a" | md5sum gives me "60b725f10c9c85c70d97880dfe8191b3", but it should be "0cc175b9c0f1b6a831c399e269772661".

If I make a reverse hash lookup for "60b725f10c9c85c70d97880dfe8191b3", I do however get "a".

1 Answer 1


The reason for the hashes being different is that echo includes a newline at the end of the output string to make it pretty. This can be prohibited by the -n flag (if your implementation of echo supports it), or by using another program (like printf):

> echo "a" | md5sum   
60b725f10c9c85c70d97880dfe8191b3  -

> echo -n "a" | md5sum
0cc175b9c0f1b6a831c399e269772661  -

> printf "a" | md5sum 
0cc175b9c0f1b6a831c399e269772661  -
  • 2
    echo adds a newline to the output to make it a complete line, not to make it pretty.
    – Kusalananda
    Jul 12, 2018 at 8:56
  • @Kusalananda Typing in printf text makes the text appear infront of the next prompt line.
    – neverMind9
    Nov 11, 2018 at 2:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .