Wget
wget
is a command-line utility used for downloading files from the internet.
It supports various protocols, including HTTP, HTTPS, FTP, and FTPS. wget
is commonly used to retrieve files and web content from the command line in Unix-like operating systems.
Basic Syntax
wget [options] [URL]
Common Options
-O
or--output-document
: Specify the output file name.-P
or--directory-prefix
: Specify the directory to save the downloaded file.-r
or--recursive
: Download recursively (follow links).-N
or--timestamping
: Download only newer files.-c
or--continue
: Resume a partially downloaded file.-q
or--quiet
: Quiet mode (suppress output).-U
or--user-agent
: Set the user agent string.-h
or--help
: Display help information.
Examples
Downloading a File:
wget https://www.example.com/file.txt
This downloads
file.txt
fromexample.com
.Downloading with Custom Output Name:
wget -O output.txt https://www.example.com/file.txt
This downloads
file.txt
fromexample.com
and saves it asoutput.txt
.Downloading to a Specific Directory:
wget -P /path/to/directory https://www.example.com/file.txt
This downloads
file.txt
to the specified directory.Recursively Downloading a Website:
wget -r https://www.example.com
This downloads the entire
example.com
website and its linked content.Resuming a Partial Download:
wget -c https://www.example.com/largefile.zip
This resumes downloading
largefile.zip
if it was interrupted or partially downloaded.Downloading Only Newer Files:
wget -N https://www.example.com/updates.tar.gz
This downloads
updates.tar.gz
only if it's newer than the existing local copy.
Advanced Usage
wget
supports advanced features like downloading through proxy servers, setting bandwidth limits, and using cookies.
Use Cases
- Downloading files from the internet.
- Mirroring websites for offline viewing.
- Batch downloading multiple files.
- Automated downloading as part of scripts.
Conclusion
wget
is a reliable tool for downloading files and web content from the command line.
Its simplicity and range of features make it a preferred choice for tasks that involve fetching resources over the internet.
✅ Resources
- 👉 Bash CheatSheet
- 👉 Deploy Projects using your own cloud provider
- 👉 Get Deployment Support from
experts