macoscurlcommand-lineterminal

How to download a file using curl


I'm on mac OS X and can't figure out how to download a file from a URL via the command line. It's from a static page so I thought copying the download link and then using curl would do the trick but it's not.

I referenced this StackOverflow question but that didn't work. I also referenced this article which also didn't work.

What I've tried:

curl -o https://github.com/jdfwarrior/Workflows.git
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information

.

wget -r -np -l 1 -A zip https://github.com/jdfwarrior/Workflows.git
zsh: command not found: wget

How can a file be downloaded through the command line?


Solution

  • The -o --output option means curl writes output to the file you specify instead of stdout. Your mistake was putting the url after -o, and so curl thought the url was a file to write to rate and hence that no url was specified. You need a file name after the -o, then the url:

    curl -o ./filename https://github.com/jdfwarrior/Workflows.git
    

    And wget is not available by default on OS X.