Monday, February 1, 2016

The Difference Between Bash and Bourne Shell When Using echo Command

Bash

$ echo -n "A. P. Balachandran" | md5
b9114dc37ab93677d533a0e3e025ee58

Bourne shell: Same value!

sh-3.2$ echo "A. P. Balachandran\c" | md5
b9114dc37ab93677d533a0e3e025ee58

Bourne shell: wrong md5 value!

sh-3.2$ echo -n "A. P. Balachandran" | md5
9e63b57c592863eaad63d37f72bce0d0

Bourne shell: -n option isn't working. That is why.

sh-3.2$ echo -n "A. P. Balachandran"
-n A. P. Balachandran