Created
April 24, 2018 20:41
-
-
Save malcolmgreaves/71a2a47716752764282bd6e3771f4293 to your computer and use it in GitHub Desktop.
Bash function for a better CLI remote file download experience.
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
#!/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}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.