0

On my Linux system, I want to generate a MD5 check sum and save it to a variable. The command to generate check sum is:

$ md5sum myfile.zip

And the output is:

060906cec6fd1037ff275d928f96b419  myfile.zip

I want to pipe this output into a read command like so:

$ md5sum myfile.zip | read sum filename

However, that does not seem to work: the variables sum and filename remains undefined. I worked around this problem by redirecting the output into a file, then read it back:

$ md5sum myfile.zip > tempfile
$ read sum filename < tempfile

What did I do wrong and how do I fix it? I appreciate your answers and comments.

Hai Vu
  • 34,189
  • 11
  • 57
  • 87

0 Answers0