bashshellmd5sum

Only get hash value using md5sum (without filename)


I use md5sum to generate a hash value for a file. But I only need to receive the hash value, not the file name.

md5=`md5sum ${my_iso_file}`
echo ${md5}

Output:

3abb17b66815bc7946cefe727737d295  ./iso/somefile.iso

How can I 'strip' the file name and only retain the value?


Solution

  • Using AWK:

    md5=`md5sum ${my_iso_file} | awk '{ print $1 }'`