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
-Oor--output-document: Specify the output file name.-Por--directory-prefix: Specify the directory to save the downloaded file.-ror--recursive: Download recursively (follow links).-Nor--timestamping: Download only newer files.-cor--continue: Resume a partially downloaded file.-qor--quiet: Quiet mode (suppress output).-Uor--user-agent: Set the user agent string.-hor--help: Display help information.
Examples
Downloading a File:
wget https://www.example.com/file.txtThis downloads
file.txtfromexample.com.Downloading with Custom Output Name:
wget -O output.txt https://www.example.com/file.txtThis downloads
file.txtfromexample.comand saves it asoutput.txt.Downloading to a Specific Directory:
wget -P /path/to/directory https://www.example.com/file.txtThis downloads
file.txtto the specified directory.Recursively Downloading a Website:
wget -r https://www.example.comThis downloads the entire
example.comwebsite and its linked content.Resuming a Partial Download:
wget -c https://www.example.com/largefile.zipThis resumes downloading
largefile.zipif it was interrupted or partially downloaded.Downloading Only Newer Files:
wget -N https://www.example.com/updates.tar.gzThis downloads
updates.tar.gzonly if it's newer than the existing local copy.
Advanced Usage
wgetsupports 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