What is Wget?
Wget is a simple Linux/Unix command-line utility for downloading the contents, and files from the web. Wget will download the resource from the URL which is specified in the command. With the help of wget, we can download files using HTTP, and HTTPS. We can also download multiple files, resume downloads, recursive downloads, downloads in the background, and different options in the wget command.
In this article, let’s see how to install and, use this command with examples.
Installing Wget
The wget is pre-installed on most of the Linux distros.
To verify whether the package is installed, open your terminal type wget and press enter. You will get a result of wget: missing URL. If the wget package is not installed it will print wget command not found.
Installation on Ubuntu and Debian
Wget installation on macOS
brew install wgetSyntax:
Download a File/Files with wget
Without specifying an option
wget will download the files specified in the URL to the current directory.
In the following example, we download the sample file.
Command:
wget https://file-examples.com/index.php/sample-documents-download/sample-doc-download/#
The index.html file is downloaded in the home directory.
Hide an Output
To hide an output in the terminal use the
-qoption.Command:
wget -q https://file-examples.com/index.php/sample-documents-download/sample-doc-download/#
Once the download is complete you can find the file in your current directory.
Downloading a file in a specific directory
To save the file in a specific location, use the -P Option.
Syntax:
wget -P <PATH> <URL>
Example
wget -P /home/aravind/Downloads https://file-examples.com/index.php/sample-documents-download/sample-doc-download/#Download in Background
Use
-boption to download in the background.Command:
wget -b /home/aravind/Downloads https://file-examples.com/index.php/sample-documents-download/sample-doc-download/#
Check the
wget-logFile in the current directory where the output is redirected.
To check the log, use the
tailcommandCommand:
tail wget-logDownloading Multiple files
To download multiple files at once,
Create a file that contains a list of the URLs to be downloaded. Each URL is separated by a line. Use
-ioption followed by the path of the links file.The file
sample-links.txtcontains four different links
https://file-examples-com.github.io/uploads/2017/02/file-sample_500kB.dochttps://file-examples.com/index.php/sample-audio-files/sample-ogg-download/https://file-examples.com/index.php/sample-images-download/sample-jpg-download/Command:
wget -i sample-links.txtThe downloaded files are stored in my current directory.
So, here we came to an end these are the top options used for wget.
Thanks for reading 😀😀






Very simple and easy to understand
ReplyDelete