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?

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

1 Answer 1

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.

1
  • 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. Apr 4, 2013 at 21:25

You must log in to answer this question.

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