I need to get the md5 sum of a file on AIX, but the md5sum program prints the sum followed by the name of the file.
How can I get the sum without the file name.
Also:
md5sum filename | cut -c -32
Which has the benefit of having no quotes or characters needing to be escaped, in case you need to embed that command someplace which might have multiple string interpreters acting on it.
Another way is to do :
md5sum filename |cut -f 1 -d " "
Cut will split line to each space and return only first field.
A very simple way is to assign the output to an array as explained here:
md5=( $(md5sum "filename") )
echo $md5
Another way is to strip the space and anything after it:
md5=$(md5sum "filename")
echo ${md5/ *}