0

Why do I become a different hash when I try:
md5 <<< "Hello"
md5 -s "Hello"
Is it because of a possible line break in the first example?

  • 2
    When in doubt, dump your data. od -xa <<< 'Hello' or xxd <<< 'Hello' will show you an extra trailing newline. – manatwork Apr 4 '13 at 15:12
2

Heredocs (thats what <<< is called) in bash always end with a newline character. There is no way to disable this behavior. This newline character is what is throwing off the checksum.

  • Note that bash copied that feature (called herestring not heredoc) from ksh93 which itself copied it from zsh which itself copied it from the Plan 9 shell rc. rc did not add the trailing newline character. ksh93, zsh and bash do. – Stéphane Chazelas Apr 4 '13 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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