wget Command on macOS Terminal


mac ~ % wget
zsh: command not found: wget

If you try the wget command on your Mac you would get a command not found error, that's because you would need to install the wget package.

How to install wget in macOS?

  • Open Terminal App,
  • Type command: brew install wget

If you do not have brew installed: follow this article: How to install brew on Mac (M1)

Examples: wget

@mac ~ % wget https://code2care.org
--2021-08-08 14:28:40--  https://code2care.org/
Resolving code2care.org (code2care.org)... 104.21.91.10, 172.67.164.66
Connecting to code2care.org (code2care.org)|104.21.91.10|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

index.html     [ <=> ]  35.74K  --.-KB/s    in 0.02s   

2021-08-08 14:28:40 (2.16 MB/s) - ‘index.html’ saved [36601]

You can know more about the command by using the help "wget --help"

wget --help
GNU Wget 1.21.1, a non-interactive network retriever.
Usage: wget [OPTION]... [URL]...

Mandatory arguments to long options are mandatory for short options too.

Startup:
  -V,  --version                   display the version of Wget and exit
  -h,  --help                      print this help
  -b,  --background                go to background after startup
  -e,  --execute=COMMAND           execute a `.wgetrc'-style command

If you provide an invalid URL you will get an unable to resolve address error,

If you do not provide a URL you will get an error,

mac ~ % pwd
/Users/code2care
code2care@mac ~ % cd Desktop 
code2care@mac Desktop % wget abc
--2021-08-08 14:31:47--  http://abc/
Resolving abc (abc)... failed: nodename nor servname provided, or not known.
wget: unable to resolve host address ‘abc’
mac Desktop % wget abc
--2021-08-08 14:31:47--  http://abc/
Resolving abc (abc)... failed: nodename nor servname provided, or not known.
wget: unable to resolve host address ‘abc’



Recent Posts:




Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.