Skip to content

Instantly share code, notes, and snippets.

@jriguera
Created June 7, 2015 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jriguera/09387f137bd84d339a5d to your computer and use it in GitHub Desktop.
Save jriguera/09387f137bd84d339a5d to your computer and use it in GitHub Desktop.
Pretty download wrapper for wget
#!/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