Understanding the wget Command

Basic Usage of wget

The wget command is a widely used utility for non-interactive downloading of files from the web. It supports HTTP, HTTPS, and FTP protocols and can handle recursive downloads, making it very powerful for retrieving content from websites.

wget [OPTIONS] [URL]

Common Options for wget

wget has a variety of options to customize its behavior:

Examples of wget Command

Download a Single File

wget https://example.com/file.zip

This command downloads the specified file from the provided URL.

Download a File and Save with a Different Name

wget -O newfile.zip https://example.com/file.zip

This command downloads the file and saves it as newfile.zip.

Download a Webpage and Its Assets

wget -p https://example.com

This command downloads the specified webpage along with all the assets required to display it properly.

Download Files Recursively

wget -r https://example.com/files/

This command recursively downloads all files from the specified directory.

Limit Download Speed

wget --limit-rate=200k https://example.com/largefile.zip

This command limits the download speed to 200 KB/s.

Understanding wget Output

The output of the wget command includes information about the download progress, including:

Summary of Options

Option Description
-V, --version Display version information and exit.
-h, --help Display a help message and exit.
-b, --background Go to background after startup.
-N, --timestamping Don't re-download files unless newer.
-P Set the directory prefix to directory.
-r, --recursive Download files recursively.
-l Set the maximum recursion depth.
-k, --convert-links Convert links for local viewing.
-p, --page-requisites Download all necessary elements for HTML pages.
-q, --quiet Turn off output.
-c, --continue Resume a partially downloaded file.
-O Save the downloaded file as file.
--limit-rate= Limit the download speed to rate.