Skip to main content

Wget & curl

Wget

Command syntax

wget [option] [URL]

Download sequence of files using Bash range syntax

wget http://example.com/file_{1..4}.webp

Useful options

OptionDescription
--continue (-c for short)Resume a previously interrupted download.
--debugDisplay request and response headers.
--header="name: value"Add or update a request header.
-l depthMaximum depth level for recursion, inf can be used for unlimited.
-mTurns on recursion and time-stamping, sets infinite recursion depth and keeps FTP directory listings.
--no-parentDo not ascend to the parent directory when retrieving recursively. Only the files below a certain hierarchy will be downloaded.
--no-proxyDon't use proxies, even if the appropriate *_proxy environment variable is defined.
-O fileNameSave target as fileName. If - is used as argument, documents will be printed to standard output.
-rTurn on recursive retrieving. The default maximum depth is 5.
--show-progressDisplay the progress bar (in any verbosity).
--user=usr --password=pwdSpecify the username and password to be used for both FTP and HTTP authentication.

curl

Basic usage of the command is the same as wget.

Useful options

OptionDescription
-A 'Mozilla/5.0'Set user-agent
-x proxy:portUse HTTP proxy
-H 'Authorization: bearer-token'Use custom header
-u username:passwordHTTP Basic Authentication
-LFollow any redirects until final destination is reached
-X PUTSet request method; if not passed GET is used by default
-X POST -d 'key1=val1&key2=val2'Specify key-value pairs in request body
-X POST -d 'key1=val1' -d 'key2=val2'Alternative way of sending multiple keys and values
-X POST -d '{"k1":v1}' -H 'Content-Type: application/json'Use JSON data
-o output.txtSave response to a file
-ODownload a file and save it as the same name
-O -CContinue a partial download
-O --limit-rate 1MTransfer rate limited to 1MB/s