Skip to content

Instantly share code, notes, and snippets.

@malcolmgreaves
Created April 24, 2018 20:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malcolmgreaves/71a2a47716752764282bd6e3771f4293 to your computer and use it in GitHub Desktop.
Save malcolmgreaves/71a2a47716752764282bd6e3771f4293 to your computer and use it in GitHub Desktop.
Bash function for a better CLI remote file download experience.
#!/bin/bash
# Bash function to download a file with wget, showing a progress bar and enables
# re-downloading if interrupted. Also can automatically determine filename from
# supplied URL or override from command line.
# First argument is URL.
# Second optional argument is filename.
download () {
local URL="$1"
local FI="$2"
if [[ -z "${FI}" ]]
then
FI="${URL}"
FI="${FI##*/}"
fi
wget --show-progress --continue --output-document="${FI}" "${URL}"
}
@malcolmgreaves
Copy link
Author

Bash function to download a file with wget, showing a progress bar and enables re-downloading if interrupted. Also can automatically determine filename from supplied URL or override from command line.

First argument is URL.
Second optional argument is filename.

E.g.

download https://en.wikipedia.org/wiki/Marvel_Science_Stories wiki-Marvel_Science_Stories.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment