Only get hash value using md5sum (without filename)
On Mac OS X:
md5 -q file
A simple array assignment works... Note that the first element of a Bash array can be addressed by just the name
without the [0]
index, i.e., $md5
contains only the 32 characters of md5sum.
md5=($(md5sum file))
echo $md5
# 53c8fdfcbb60cf8e1a1ee90601cc8fe2
Using AWK:
md5=`md5sum ${my_iso_file} | awk '{ print $1 }'`
You can use cut
to split the line on spaces and return only the first such field:
md5=$(md5sum "$my_iso_file" | cut -d ' ' -f 1)