Using the wget Command
The wget command is used to download files from the web.
It's a powerful tool for downloading single files, entire websites, or even batch downloads.
Basic Usage
To download a file, use wget url :
Example
wget http://example.com/file.txtOptions
The wget command has options to change how it works:
- -b - Run in the background
- -q - Quiet mode (no output)
- -r - Download directories recursively
- -c - Continue getting a partially-downloaded file
- --limit-rate - Limit download speed
Run in the Background
The -b option allows you to run wget in the background.
This is useful for long downloads that you don't want to monitor continuously.
Example: Run in the Background
wget -b http://example.com/file.txtQuiet Mode
The -q option allows you to run wget in quiet mode.
This is useful for scripts or automated tasks where output is not needed.
Example: Quiet Mode
wget -q http://example.com/file.txtRecursive Downloads
The -r option allows you to download directories recursively.
This is useful for downloading entire websites or directories.
Example: Recursive Downloads
wget -r http://example.com/directory/Continue Getting a Partially-Downloaded File
The -c option allows you to continue downloading a file that was partially downloaded. This is useful for resuming interrupted downloads.
Understanding Wget Output
The output of the wget command can vary depending on the options used. Here are some common elements:
- Download Progress: Shows the progress of the download.
- File Size: The size of the file being downloaded.
- Download Speed: The speed at which the file is being downloaded.
- Time Remaining: Estimated time remaining for the download to complete.
Batch Downloads
Wget can be used for batch downloads. For example, wget -r http://example.com/directory/ downloads all files in a directory.
Example: Batch Downloads
wget -r http://example.com/directory/