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 Answer
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
bashcopied that feature (called herestring not heredoc) fromksh93which itself copied it fromzshwhich itself copied it from the Plan 9 shellrc.rcdid not add the trailing newline character.ksh93,zshandbashdo.Stéphane Chazelas– Stéphane Chazelas2013-04-04 21:25:31 +00:00Commented Apr 4, 2013 at 21:25
od -xa <<< 'Hello'orxxd <<< 'Hello'will show you an extra trailing newline.