Eu acho que você quer algo assim
cat output
file1, md5sum abcdefgh
file2, md5sum 21safdsg
file3, md5sum abcdefgh
file4, md5sum 21safdsg
awk -F, '{split($2,a," "); f[a[2]]=$1" "f[a[2]]} END { for (x in f) { sub(/ /,",",f[x]); print f[x],x } } ' output
file4,file2 21safdsg
file3,file1 abcdefgh