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

Getting started with WSL

I recently started learning Linux operating system. I have a windows machine. I searched for what are the possible ways available to work with Linux. I ended up with more ways to install Linux and work with it. WSL is one of the simplest ways to get started with Linux on windows. So, I'll be sharing my learnings about WSL. It's obvious that to learn Linux one should have a Linux-based machine to work with and execute commands. There are four possible ways to get started with Linux. Possible ways to work with Linux Building a Linux-based computer which is quite expensive. I myself don't prefer to build a machine when I am a Student. Installing and using Linux in dual boot mode with your existing Windows using a virtual box. This is one of my preferred ways but it consumes more storage. So, this too fails. And the next way is to create instances in cloud platforms like AWS, GCP, and Azure and using remotely. Also, there is no cost associated with it. Because major cloud platf...

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

Why you need Linux Right Now!

  Introduction Linux is an open-source operating system created in 1991 by Linus Torvalds. It's an alternative to the more popular Windows and Mac operating systems, and it comes with a wide range of features that make it a great choice for everyone, from beginners to seasoned professionals. In this blog, we'll discuss what Linux is, what it can offer you, and why you should start using it today. What Is Linux? Linux is used today by millions of people worldwide, including large corporations, small businesses, government organizations, and individuals. There are many reasons why you should use Linux. Here are a few: Linux is stable and secure. It is less likely to crash or become infected with a virus than Windows. Linux is customizable. You can change the look and feel of Linux to suit your needs, and you can add or remove software to create the perfect operating system for you. Linux is free. There are no licensing fees required to use Linux, and there are many free applicati...