Overview
wget is a powerful command-line utility used for downloading files from the web. It is particularly useful in scripts or automated tasks, and can be used to mirror complex websites or download single files.
Key Features
- Non-interactive download: Can run in the background without user interaction.
- Supports download resuming: Continues downloading partially downloaded files.
- Recursive download: Mirrors entire websites or parts of them.
- Proxy and authentication support: Usable in various network environments.
Key Options
wget's various options allow for fine-grained control over download methods, output formats, file saving locations, and more.
Output and Logging
File Saving and Resuming
Recursive Download
Generated command:
Try combining the commands.
Description:
`wget` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Examples
Examples of various file downloads and website mirroring using the wget command.
Basic File Download
wget https://example.com/sample.zip
Downloads a file from the specified URL.
Hide Download Progress (-nv)
wget -nv https://example.com/large_file.tar.gz
Downloads a file without progress messages. Error messages are still displayed.
Save Log to File (-o)
wget -o wget_log.txt https://example.com/another_file.pdf
Records all messages during the download process to 'wget_log.txt'.
Specify Output File Name (-O)
wget -O my_document.html https://example.com/index.html
Saves the downloaded file as 'my_document.html'.
Save to a Specific Directory (-P)
wget -P /tmp/downloads https://example.com/image.jpg
Saves the downloaded file to the '/tmp/downloads' directory.
Hide Progress and Log to File
wget -nv -o download.log https://example.com/data.csv
Downloads a file while hiding progress and logging all messages to 'download.log'.
Resume Download (-c)
wget -c https://example.com/very_large_file.iso
Resumes downloading 'very_large_file.iso', which was partially downloaded previously.
Tips & Precautions
wget is a powerful tool, but misuse can overload servers. Be cautious and review these tips for efficient and safe usage.
Tips for Efficient Usage
- For large file downloads, use the `-c` option to resume downloads, ensuring stable downloads even with unstable network connections.
- When using in scripts or automated tasks, use `-q` or `-nv` options to suppress unnecessary output, making log file management easier.
- When downloading recursively, use `-np` with `-r` to prevent unintended downloads of parent directories and to mirror only within a specific path.
- Consider using the `--limit-rate` option to limit download speed and avoid overloading servers.
- To download in the background, use the `-b` option, and combine it with `nohup` to ensure the download continues even after the session ends.