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?
The -o --output
option means curl writes output to file you specicify instead of stdout, you put the url after -o
, so the curl thinks the url is a file to write and no url specified. You need a file name after the -o
, then the url. Since the url is HTTPS-based, maybe you also need the -k
option:
curl -o ./filename -k https://github.com/jdfwarrior/Workflows.git
And wget is not available by default on OS X.
The easiest solution for your question is to keep the original filename. In that case, you just need to use a capital o ("-O") as option (not a zero=0!). So it looks like:
curl -O https://github.com/jdfwarrior/Workflows.git
curl -OL https://github.com/jdfwarrior/Workflows.git
-O
: This option used to write the output to a file which named like remote file we get. In this curl that file would be Workflow.git
.
-L
: This option used if the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place.
Ref: curl man page