Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
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
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
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. –  Stephane Chazelas Apr 4 '13 at 21:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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