2013-12-08 08:56:16 +00:00
|
|
|
# curl
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
> Transfers data from or to a server.
|
2017-06-26 11:13:01 +01:00
|
|
|
> Supports most protocols, including HTTP, FTP, and POP3.
|
2021-02-07 20:27:41 +00:00
|
|
|
> More information: <https://curl.se>.
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2016-08-31 19:33:33 +01:00
|
|
|
- Download the contents of an URL to a file:
|
A bunch of new pages:
common/: dig, gzip, rm, sort, zfs, zpool
linux/: apt-get, shutdown
osx/: airport, caffeinate, diskutil, networksetup open, pgrep, qlmanage, say, shutdown, sysctl, system_profiler
Edits to existing pages:
curl: Added simple download example
find: Added iname and size exmaples
grep: Edited -c description
ps: Added wide lines example
ssh: edited -D description, added simple port forwarding example
unzip: added list option
2014-02-10 20:36:05 +00:00
|
|
|
|
2021-05-04 10:37:07 +01:00
|
|
|
`curl {{http://example.com}} --output {{filename}}`
|
A bunch of new pages:
common/: dig, gzip, rm, sort, zfs, zpool
linux/: apt-get, shutdown
osx/: airport, caffeinate, diskutil, networksetup open, pgrep, qlmanage, say, shutdown, sysctl, system_profiler
Edits to existing pages:
curl: Added simple download example
find: Added iname and size exmaples
grep: Edited -c description
ps: Added wide lines example
ssh: edited -D description, added simple port forwarding example
unzip: added list option
2014-02-10 20:36:05 +00:00
|
|
|
|
2017-06-26 11:13:01 +01:00
|
|
|
- Download a file, saving the output under the filename indicated by the URL:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2021-05-04 10:37:07 +01:00
|
|
|
`curl --remote-name {{http://example.com/filename}}`
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2021-05-04 10:37:07 +01:00
|
|
|
- Download a file, following location redirects, and automatically continuing (resuming) a previous file transfer:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2021-05-04 10:37:07 +01:00
|
|
|
`curl --remote-name --location --continue-at - {{http://example.com/filename}}`
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2021-05-04 10:37:07 +01:00
|
|
|
- Send form-encoded data (POST request of type `application/x-www-form-urlencoded`). Use `--data @file_name` or `--data @'-'` to read from STDIN:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2021-05-04 10:37:07 +01:00
|
|
|
`curl --data {{'name=bob'}} {{http://example.com/form}}`
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2017-06-26 11:13:01 +01:00
|
|
|
- Send a request with an extra header, using a custom HTTP method:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2021-05-04 10:37:07 +01:00
|
|
|
`curl --header {{'X-My-Header: 123'}} --request {{PUT}} {{http://example.com}}`
|
2017-06-06 08:23:00 +01:00
|
|
|
|
|
|
|
- Send data in JSON format, specifying the appropriate content-type header:
|
|
|
|
|
2021-05-04 10:37:07 +01:00
|
|
|
`curl --data {{'{"name":"bob"}'}} --header {{'Content-Type: application/json'}} {{http://example.com/users/1234}}`
|
2016-01-12 19:24:22 +00:00
|
|
|
|
2017-06-26 11:13:01 +01:00
|
|
|
- Pass a user name and password for server authentication:
|
2014-03-11 15:01:45 +00:00
|
|
|
|
2021-05-04 10:37:07 +01:00
|
|
|
`curl --user myusername:mypassword {{http://example.com}}`
|
2016-01-28 12:12:55 +00:00
|
|
|
|
2017-04-19 19:25:38 +01:00
|
|
|
- Pass client certificate and key for a resource, skipping certificate validation:
|
2016-01-28 12:12:55 +00:00
|
|
|
|
2017-04-19 10:22:34 +01:00
|
|
|
`curl --cert {{client.pem}} --key {{key.pem}} --insecure {{https://example.com}}`
|