Howto Install wget for Mac OS X

The wget command is used to download files from the web and is one of the most useful commands around. But while it comes included with most distributions of Linux, it is not built into Mac OS X by default. Therefore, let’s look at installing wget.

To get started, install the developer tools for Mac OS X so that you can get a working copy of a compiler (gcc). Once the developer tools have been installed, you’ll want to download the latest version of wget from gnu. To do so, either download it manually from http://www.gnu.org/software/wget or use the ftp command to do so for you:

ftp ftp://ftp.gnu.org/gnu/wget/wget-latest.tar.gz

Next, extract the tar file using the tar command:

tar -xvzf wget-latest.tar.gz

You will then have a directory called wget- followed by the version of wget you just downloaded (currently 1.12). Let’s cd into that directory:

cd wget-1.12

Then run the configure script:

./configure

Then make the installer:

make

Then run the installer (with elevated privileges:

make install

You will then have the wget command located in /usr/local/bin/wget. To use it, simply use wget, followed by the path to the file you’d like to download using the –tries option:

wget –tries=10 http://www.krypted.com/scripts/wget.sh

There are a lot of options for wget, but some that I use more than others include –user= and –password=, which allows you to authenticate to a host by specifying a username and a password (respectively of course) and –limit-rate, which funny enough, let’s you throttle the speeds of transfers so as not to saturate your bandwidth. I also frequently need to use the -r operator, which allows for recursive downloads and the -o operator which outputs to a log file. Overall wget is one of the most useful commands around, and hopefully after reading this you’ll download it and get used to using it (if you weren’t already).