

When it comes to downloading files from the web, Wget is a powerful command-line tool that offers a wide range of features and options. Whether you need to download a single file, retrieve multiple files, or mirror an entire website, Wget provides the flexibility and control you need. In this article, we will explore some of the most useful commands of Wget that can enhance your file downloading experience and make your workflow more efficient. By incorporating these commands into your usage of Wget, you can optimize your file downloads and save valuable time.
Table of Contents
- Introduction
- Download a Single File
- Download Multiple Files
- Limit Download Speed
- Save a File with a Different Name
- Resume Interrupted Downloads
- Download a File and its Associated Resources
- Specify Download Directory
- Download Files from a List
- Mirror a Website
- Specify User Agent String
- Conclusion
Introduction
Wget is a command-line utility that enables you to download files from the web using various protocols such as HTTP, HTTPS, and FTP. Its versatile nature and extensive options make it a preferred choice for many users. By understanding and utilizing the following commands, you can harness the full potential of Wget and optimize your file downloading process.
Useful Commands of Wget to Download a Single File
To download a single file using Wget, simply execute the following command, replacing [URL]
with the URL of the file you want to download:
wget [URL]
This command will initiate the download of the specified file and save it in your current directory.
Download Multiple Files
Wget also allows you to download multiple files in one go. To do so, provide the URLs of the files you want to download separated by spaces, like this:
wget [URL1] [URL2] [URL3] ...
Executing this command will initiate parallel downloads for all the specified files.
Limit Download Speed
Sometimes, you may want to control the download speed to ensure that it doesn’t consume excessive bandwidth. You can achieve this by using the --limit-rate
option. Replace [rate]
with the desired download speed in bytes per second:
wget --limit-rate=[rate] [URL]
This command will restrict the download speed to the specified rate, allowing you to manage your network resources effectively.
Save a File with a Different Name
If you wish to save a downloaded file with a different name, you can use the -O
option. Replace [filename]
with the desired name:
wget -O [filename] [URL]
By employing this command, you can conveniently organize your downloaded files and provide them with more meaningful names.
Resume Interrupted Downloads
Wget allows you to resume downloads that were interrupted or paused. This feature comes in handy when you have a large file to download and want to continue from where you left off. Execute the following command to resume a download:
wget -c [URL]
Wget will check the partially downloaded file and fetch the remaining data, ensuring a seamless download experience.
Download a File and its Associated Resources
In situations where you need to download a file along with its associated resources (such as images, stylesheets, or scripts), the -p
option proves useful. Execute the following command:
wget -p [URL]
Specify Download Directory
By default, Wget saves downloaded files in the current directory. However, you can specify a different directory using the -P
option. Replace [directory]
with the desired path:
wget -P [directory] [URL]
This command ensures that downloaded files are saved in the specified directory, allowing for better organization and management.
Download Files from a List
Suppose you have a text file ([file.txt]
) containing a list of URLs you want to download. In that case, you can instruct Wget to read the file and initiate downloads for each URL using the -i
option:
wget -i [file.txt]
Wget will parse the file and sequentially download all the listed URLs, making it convenient to download multiple files at once.
Mirror a Website
Wget’s powerful mirroring capability allows you to download an entire website for offline browsing or archival purposes. Execute the following command to mirror a website:
wget -r [URL]
This command initiates a recursive download, fetching all the files and directories that make up the specified website.
Specify User Agent String
In some cases, you may want to specify a custom user agent string to emulate different web browsers or devices. You can achieve this using the --user-agent
option. Replace [user-agent-string]
with the desired string:
wget --user-agent=[user-agent-string] [URL]
By customizing the user agent string, you can access content that is specific to certain browsers or devices.
Learn how to find 404 Errors with wget
Conclusion
Wget offers a plethora of commands and options that empower you to have fine-grained control over your file downloads. By utilizing these commands in your workflow, you can enhance your productivity, streamline the downloading process, and ensure efficient file management.
[…] READ ALSO : Useful Commands of Wget for Efficient File Downloads […]
[…] More useful Commands of Wget […]