Possible Duplicate:
How to get the MD5 hash of a string directly in the terminal?
I have a given variable and I have to calculate its md5sum. I have tried with "md5sum $variable", but it doesn't work.
Possible Duplicate:
How to get the MD5 hash of a string directly in the terminal?
I have a given variable and I have to calculate its md5sum. I have tried with "md5sum $variable", but it doesn't work.
md5sum takes filenames as parameters.
Iif you have a string you want to calculate the hash of, you need to pass it to md5sum's standard input via a pipe:
echo -n $variable | md5sum
(-n to suppress adding a newline)
"$variable"
, otherwise leading and trailing spaces are not taken into account, as multiple consecutive spaces inside the content of variable.
I think you could try this:
echo -n "$VARIABLE" | md5sum
As suggested in comments, echo -n
should will not add a new line. Also, using quotes will keep new lines as in original content.