Updated some stuff, now it's working.
First download the file:
wget http://source.tar.gz
Then download the md5sum of file.
wget http://source.md5 -o source.tar.gz.md5
So it looks like this:
$ ls
source.tar.gz
source.tar.gz.md5
Then: vi /bin/md5check.sh
#!/bin/bash
key=$1
[ ! -f "$key" ] && echo "sth done: There is no md5 file to check: $key" && exit
[ ! -f "${key%.*}" ] && echo "sth done: There is no source file to check: ${key%.*}" && exit
[ ! "${key##*.}" == "md5" ] && echo "usage:$0 file.tar.gz.md5" && exit
mdsum=(`md5sum -- "${key%.*}"`);
mdsum_md5=(`head -n1 "$key"`);
[ "${mdsum}" == "" ] || [ "${mdsum_md5}" == "" ] && echo "Propably program error, check spaces or special characters in filenames. md5sum:"${mdsum}" file:"${mdsum_md5} && return;
if [ "${mdsum}" == "$mdsum_md5" ];
then echo " done: CHECKED all ok"
else echo -e " done: WARRNING MD5 sums are not equal!\t(${key})" && echo $mdsum && head -n1 "$key"
fi
and
chmod 700 md5check.sh
So I can
./md5check.sh source.tar.gz.md5
done: CHECKED all ok
./md5check.sh source.tar.gz.md5
done: WARRNING MD5 sums are not equal! (source.tar.gz.md5)
db41373e270b06c00dd3d2c89b95899a
db21373e270b06c00dd3d2c89b95899a source.tar.gz
And where is the download part mentioned earlier?
wget http://source.tar.gz && wget http://source.md5 -o source.tar.gz.md5 && /bin/md5check.sh source.tar.gz.md5
Now you can alias it:
this is wrong: alias md5dl="wget $1 && wget $2 -o $(basename $1).md5 && /bin/md5check.sh $(basename $1).md5"
Still don't know, why aliases don't want to function like above, so if using bash vi .bash_profile
and add:
function md5dl() {
wget $1 && wget $2 -o $(basename $1).md5 && /bin/md5check.sh $(basename $1).md5
}
Reload profile source .bash_profile
And final move would be:
md5dl http://download.com/me.zip http://download.com/me.md5
But in my opinion: better way is to (1st) download all the required files and (2nd) then compare, all types 'md5,asc,sign,sha1' at once in download directory.
Even better would be monitor and auto check download folder for 'md5,asc,sign,sha1'.