Hmm. I downloaded 2 files, and don’t know if they are equal. Worse, they are not of the same size and I don’t know if one’s file content is corrupted.
#!/bin/sh
a=$1
b=$2
sizea=$(($(wc -c < $a)))
sizeb=$(($(wc -c < $b)))
if [[ $sizea == $sizeb ]]; then
if [[ $(md5sum $a $b|sort -u|wc -l) == "1" ]]; then
echo "equal"
else
echo "different, but same size"
fi
else
if [[ $(($sizea < $sizeb)) == "1" ]]; then
tmp=$a; a=$b; b=$tmp
tmp=$sizea; sizea=$sizeb; sizeb=$tmp
fi
uniq=$({ \
dd if=$a bs=1 count=$sizeb 2>/dev/null | md5sum; \
md5sum < $b; \
}|sort -u|wc -l)
if [[ $uniq == "1" ]]; then
echo "$b is the first part of $a," $sizeb "bytes ("$(($sizeb*100/$sizea))"%)"
else
echo "different files"
fi
fi
Recent Comments