Skip to content

Instantly share code, notes, and snippets.

@nknskn
Last active February 25, 2016 04:23
Show Gist options
  • Save nknskn/3fbc365a76205d871ac8 to your computer and use it in GitHub Desktop.
Save nknskn/3fbc365a76205d871ac8 to your computer and use it in GitHub Desktop.
curl and get hash sum
#!/bin/sh
# usage: ./fileDownload.sh [targeturl] [savefilename]
# Tested on: Mac OS X 10.10.5
# Build Version: 14F1605
#
# ex.
# $ ./fileDownload.sh http://free.nchc.org.tw/linuxmint/isos//stable/17.3/linuxmint-17.3-mate-32bit.iso linuxmint-17.3-mate-32bit.iso
# % Total % Received % Xferd Average Speed Time Time Time Current
# Dload Upload Total Spent Left Speed
# 100 1480M 100 1480M 0 0 4222k 0 0:05:58 0:05:58 --:--:-- 4232k
# MD5 (linuxmint-17.3-mate-32bit.iso) = 41c191ead435b895e74098c35519c8a2
# c91076dc8db7979572ebcba2e9fa5c06b995807b linuxmint-17.3-mate-32bit.iso
# c571f805bed447ec335e43a2092caf86aba72a8341ef59964efae9da9658b3ca linuxmint-17.3-mate-32bit.iso
curl $1 >> $2
if [ $? -eq 0 ]; then
md5 $2
# md5sum $2
shasum $2
# sha1sum $2
shasum -a 256 $2
# sha256sum $2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment