The wget is a very useful tool in order to make requests to the different protocols like HTTP, HTTPS, FTP etc. via a command-line interface. It is created for the Unix and Linux operating systems to work via command-line interface without the need for a GUI or graphical user interface. The wget supports a lot of different protocols and features. As a Unix-based operating system, the MacOS operating system is also supported by the wget command. In this tutorial, we examine how to install and use wget command in MacOS based operating systems.
Install Xcode On MacOS
The Xcode can be used to install wget command. But first, the Xcode should be installed via iTunes.
$ xcode-select --install
Install wget via Source Code On MacOS
The wget command is a project of the GNU and the source code of the wget is provided the GNU official website. So first we will download the wget source code which can be done via the Chrome, Firefox or curl command. The latest version of the wget source code is provided with the name of “wget-latest.tar.gz”.
https://ftp.gnu.org/gnu/wget/wget-latest.tar.gz
$ curl https://ftp.gnu.org/gnu/wget/wget-latest.tar.gz
The compressed source code can be extracted with the tar
command like below.
$ tar -zxvf wget-latest.tar.gz
Navigate to the extracted directory with the cd command.
$ cd wget-latest/
The configure
script is used to prepare for the compilation.
$ ./configure
The last step is compilation and installation which can be done with the make
and make install
commands like below.
$ make && make install
Install wget via Homebrew On MacOS
The homebrew can be also used to install wget command. The homebrew is a package manager for the MacOS operating systems and makes the 3rd party application installation easier. The homebrew provides the installation script for the Xcode which is required for the wget command.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Now the homebrew command can be used to install wget with the following command. The package name is the same as wget command.
$ brew install wget
Download Single File
The wget supports different protocols where HTTP is one of them. By using the wget an HTML page can be downloaded like below.
$ wget https://linuxtect.com/home.html