Table of Contents
Date: 11-11-2015
Use wget
to download files from any location (internet, ftp, etc.) in a terminal window.
Download and Install wget
Windows
Download the executable file from https://eternallybored.org/misc/wget/. Choose the 32-bit or 64-bit version based on your system.
Copy the downloaded wget.exe
file into the C:\Windows\System32 directory. This allows you to run wget
from any command prompt.
Open a terminal window and run:
wget -V
to verify the installation.
macOS
If needed, install homebrew
using the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
To install wget
run:
brew install wget
Run
wget -V
to verify the installation.
Linux
wget
is often pre-installed on Linux systems.
To check if it is installed run
wget -V
If not installed use your distribution's package manager to install it:
Debian/Ubuntu:
apt-get install wget
Fedora/CentOS:
yum install wget
Syntax
wget <path to file>
Path Types
http://host[:port]/directory/file
https://host[:port]/directory/file
ftp://host[:port]/directory/file
Options
-v | Shows progress and other verbose information |
-nc | Prevents overwriting if same file exists in the current directory |
-c | Auto-resumes download should it be interrupted |
-w | Set number of seconds for download to wait before beginning (i.e. -w=30 will cause a 30 second wait before the download is tried) |
-4 | Uses IPv4 only |
-6 | Uses IPv6 only |
--user | Allows a username to be included (useful for https and ftp connections) |
--password | Allows the password to be included (note: passed plaintext) |
--ask-password | Prompts for password after connection is established |
-P | Allows you set a prefix on all directories created (i.e. -P Sub will cause all directories created by the download to start with Sub…) as well as allowing you to specify a download location (i.e. -P /tmp/ will cause the download to be placed in the /tmp directory) |