Download files from the internet without opening a browser. Use wget on your Mac to grab resources quickly. This command-line tool supports HTTP, HTTPS, and FTP protocols. It runs in the background without user interaction.

What is wget on Mac and Why Use It?

wget is an open-source tool from the GNU project. It downloads files from specified URLs through the command line. The tool works independently of your login session. Poor network conditions do not stop wget from completing downloads.

The utility resumes interrupted downloads automatically. You can run batch operations while working on other tasks. Many developers rely on wget for mirroring websites and downloading large files.

How to Install wget on Mac

macOS does not include wget by default. Install a package manager first. Homebrew is the standard choice for Mac users.

1. Download and Install Homebrew

Open Terminal from Applications/Utilities. Run this command:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

The curl command downloads the installer script. Press Enter to start the installation. The installer displays what changes it will make to your system.

Confirm the installation when prompted. Wait for the process to complete. You will see a new command prompt when Homebrew finishes installing.

Note: Homebrew uses Ruby, which comes pre-installed on macOS. The installation takes several minutes depending on your connection speed.

2. Install wget From the Command Line

Run this command in Terminal:

$ brew install wget

Homebrew downloads and installs wget automatically. The process shows live progress updates. Update Homebrew first if you installed it previously:

$ brew update

Verify the installation by checking the version:

$ wget --version

The command displays version information and confirms successful installation.

Tip: Run brew update regularly to keep all packages current.

How to Use wget to Download Files on Mac

Download a single file with this syntax:

$ wget http://example.com/file.zip

The file saves to your current directory. Specify a different location with the -O flag:

$ wget -O /Users/yourname/Downloads/file.zip http://example.com/file.zip

Change to your target directory before running wget without flags:

$ cd ~/Downloads
$ wget http://example.com/file.zip

How to Download Recursive Directories

Download entire directory trees using recursive mode:

$ wget -e robots=off -r -np https://example.com/directory/

This command follows all links within the specified path. The -e robots=off flag ignores restrictions in robots.txt. The -r flag enables recursive downloading. The -np flag prevents parent directory traversal.

Flag Function
-r Enable recursive mode
-np Do not ascend to parent directory
-e robots=off Ignore robots.txt restrictions
Warning: Recursive downloads can consume significant disk space. Check available storage before mirroring large sites.

Using Additional Flags with wget on Mac

wget includes numerous options for controlling downloads and managing output.

Control How wget Downloads Resources

These flags modify download behavior:

  • -X /path/to/exclude excludes specific directories
  • -nH removes hostname directories from the path
  • --cut-dirs=2 skips the first two directory levels
  • -R index.html rejects files matching the pattern
  • -i file.txt reads URLs from an input file
  • -nc prevents overwriting existing files
  • -c continues partial downloads
  • -t 10 retries failed downloads up to 10 times

Use wildcards for pattern matching. The command -R "*.png" skips all PNG files.

Adjust Logging Output

Control what wget displays during downloads:

Flag Effect
-d Enable debugging output
-o logfile.txt Save output to specified file
-q Silent mode, no output
-v Verbose output (default)
--no-verbose Hide progress but show errors

Logging helps troubleshoot batch downloads. Save logs for large operations where errors might occur.

Alternative Installation Methods

MacPorts offers another installation option:

$ sudo port install wget

Compile from source for custom configurations. Download the source from gnu.org. Run the configuration script with your preferred options:

$ ./configure --with-ssl=openssl
$ make
$ sudo make install

Source compilation requires development tools and libraries. Most users should use Homebrew for simplicity.

Common Problems and Solutions

Connection timeouts occur with slow servers. Increase the timeout value:

$ wget --timeout=30 http://example.com/file.zip

SSL certificate errors happen with misconfigured servers. Skip verification when necessary:

$ wget --no-check-certificate https://example.com/file.zip

Resume interrupted downloads with the -c flag. wget picks up where it left off.

Warning: Only use --no-check-certificate with trusted sources. This option disables security validation.

Conclusion

wget transforms how you download content on Mac. Install it through Homebrew in minutes. The tool handles large files and poor connections efficiently. Background operation frees you to work on other tasks. Start with basic downloads. Explore advanced flags as your needs grow. The command-line approach saves time compared to browser downloads.

FAQs

No, wget does not come pre-installed on macOS. You must install it using a package manager like Homebrew or compile it from source code.

Run wget --version in Terminal. The command displays version information if wget installed successfully. An error message indicates installation problems.

Yes, use the -c or --continue flag. wget resumes the download from where it stopped without redownloading completed portions.

wget specializes in downloading files and mirroring websites recursively. curl transfers data and supports more protocols but lacks wget’s recursive download features.

Use wget -r -np -e robots=off https://example.com to recursively download all pages. Add -k to convert links for offline browsing.

Willie has over 15 years of experience in Linux system administration and DevOps. After managing infrastructure for startups and enterprises alike, he founded Command Linux to share the practical knowledge he wished he had when starting out. He oversees content strategy and contributes guides on server management, automation, and security.