Introduction
Wget command stands for 'web get,' is a versatile and free command-line tool for downloading files from the internet. It operates seamlessly in the background, allowing users to disconnect from the system while it efficiently fetches files non-interactively.
Wget is a free utility for non-interactive downloading of files from the web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies.
This guide will dissect each command, providing a detailed understanding of Wget's capabilities.
Exploring Wget's Command-Line Options
Let’s dive deeper into the wget’s command line options.
Option | Description |
---|---|
-r, --recursive | Enables recursive downloading of files and directories. |
-np, --no-parent | Restricts downloading to the current hierarchy. |
-P, --directory-prefix=PREFIX | Sets the directory where files are saved. |
-A, --accept=LIST | Downloads only files with extensions in the list. |
-R, --reject=LIST | Ignores files with extensions in the list. |
-nc, --no-clobber | Skips downloading if a file with the same name exists. |
-N, --timestamping | Downloads files only if newer than the local copy. |
-q, --quiet | Suppresses output, except for errors and download bar. |
-O, --output-document=FILE | Specifies the output file name. |
-U, --user-agent=AGENT | Sets the User-Agent header for the HTTP request. |
-h, --help | Displays help information about wget options. |
-v / --version
Description: This option is used to display the version of Wget installed on your system, providing insight into the specific build and features available to you.
Syntax:
wget -v
-h / --help
Description: This option is used to display a help message, listing all the command-line options available with Wget. It serves as a quick reference guide for users.
Syntax:
wget -h
-o logfile
Description: This option is used to log all messages from Wget to a specified logfile. It is useful for saving a record of the download process, which can be reviewed later for information or troubleshooting.
Syntax:
wget -o logfile [URL]
-b / --background
Description: This option sends the download process to the background upon initiation. It allows the user to continue with other tasks without having to wait for the download to complete.
Syntax:
wget -b [URL]
-a logfile
Description: This option appends messages to a specified logfile without overwriting the existing content. It is useful for maintaining a continuous log over multiple Wget operations.
Syntax:
wget -a logfile [URL]
-i file
Description: This option reads URLs from a specified file, allowing for batch downloading. It is particularly useful when dealing with multiple downloads, keeping the command line uncluttered.
Syntax:
wget -i file
-t number / --tries=number
Description: This option sets the number of retries for a download to a specified number. If a download fails, Wget will retry the specified number of times before giving up.
Syntax:
wget -t number [URL]
-c
Description: This option is used to resume a partially downloaded file. If a download is interrupted, Wget can pick up where it left off, saving time and bandwidth.
Syntax:
wget -c [URL]
-w seconds
Description: This option sets the interval between retrievals to a specified number of seconds. It is recommended to use this option to reduce the load on the server and to adapt to network errors or downtimes.
Syntax:
wget -w seconds [URL]
-r / --recursive
Description: This option enables recursive retrieval of websites. Wget will follow links and download entire directory structures, mirroring the layout of the original site.
Syntax:
wget -r [URL]