Words by Mário Gamito [Tue, Mar 11, 2008 at 01:07:54PM +0000]:
> I have a script that has to perform a hash over a password.
> Problem is that sha512sum expects CTRL-D to be pressed to return to the
> command prompt.
No, it just expects EOF.
> I've searched all over Google, but either I didn't use the right search
> strings or there is nothing relevant about this.
> Bottom line is that I need this command to print the password hash and
> returns to the shell automatically:
> $ sha512sum | xargs echo "password" | cut -f2 -d' '
> $ read x; echo "$x" | sha512sum | xargs echo "password" | cut -f2 -d' '
> but no good and as a bonus (NOT) the hash is incorrect.
That is because echo adds a \n at the end of the string.