Skip to main content

Wget Command

 

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

            sudo apt install wget

Wget installation on macOS

       brew install wget

Syntax:

            wget <OPTION> <URL>

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 -q option.    

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 -b option 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-log File in the current directory where the output is redirected.


To check the log, use the tail command

Command:

          tail wget-log

Downloading 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 -i option followed by the path of the links file.

The file sample-links.txt contains four different links


            https://file-examples-com.github.io/uploads/2017/02/file-sample_500kB.doc
            https://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.txt



The 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 😀😀

Comments

Post a Comment

Popular posts from this blog

PLASMONICS - A Vision of future

Surface plasmon resonance (SPR) - related science and technology have recently spawned a brand new branch of research referred to as "Plasmonics" Plasmonics, also known as nanoplasmonics, is the creation, detection, and manipulation of signals at optical frequencies at nanoscale scale metal-dielectric interactions. Following the trend of miniaturizing optical devices, plasmonics finds applications in sensing, imaging, optical communications, and bio-photonics. Surface Plasmon Resonance in Bioanalysis For almost a decade, plasmonic imaging has been used to analyze single-cell activity. Although this approach is still in its early stages, its label-free and real-time benefits have piqued curiosity, and it has already been applied to extracellular and intracellular activities. However, as a freshly developed approach, plasmonic imaging has significant flaws that must be addressed before it can be widely used. First, plasmonic imaging’s imaging capacity needs to be improved. The ...

Elasticsearch- II

 ELASTICSEARCH                                          In this blog we are going to learn how to use elasticsearch and kibana using python. Before getting into this, make sure that you have elasticsearch and kibana installed. To know the detailed procedure about the installation of elasticsearch and kibana, click the link below to learn the installation process from scratch. https://crescenttechnocratsclub.blogspot.com/2022/09/blog-post.html For python, let’s use VS Code . Visual Studio (VS) Code is a streamlined code editor with support for development operations like debugging, task running, and version control. Python IDLE is also fine to use but we will work with vs code in this blog. Install VS code using the following link : https://code.visualstudio.com/download Click op...