Created
June 7, 2015 12:22
-
-
Save jriguera/09387f137bd84d339a5d to your computer and use it in GitHub Desktop.
Pretty download wrapper for wget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
download() { | |
local url="$1" | |
local destin="$2" | |
echo -n " " | |
if [ ! -z "${destin}" ]; then | |
wget --progress=dot "${url}" -O "${destin}" 2>&1 | grep --line-buffered "%" | \ | |
sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}' | |
else | |
wget --progress=dot "${url}" 2>&1 | grep --line-buffered "%" | \ | |
sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}' | |
fi | |
echo -ne "\b\b\b\b" | |
echo "done" | |
} | |
# Example | |
kernel_url="http://stable.release.core-os.net/amd64-usr/current/coreos_production_pxe.vmlinuz" | |
echo -n "Downloading ${kernel_url}: " | |
download "${kernel_url}" "vmlinuz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment