2013-12-08 08:56:16 +00:00
|
|
|
# curl
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
> Transfers data from or to a server.
|
2016-08-31 19:33:33 +01:00
|
|
|
> Supports most protocols including HTTP, FTP, POP3.
|
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
|
|
|
|
2016-08-31 19:33:33 +01:00
|
|
|
`curl {{http://example.com}} -o {{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
|
|
|
|
2016-08-31 19:33:33 +01:00
|
|
|
- Download a file saving the output under the filename indicated by the URL:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2016-08-31 19:33:33 +01:00
|
|
|
`curl -O {{http://example.com/filename}}`
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2017-02-02 11:35:43 +00:00
|
|
|
- Download a file, following [L]ocation redirects, and automatically [C]ontinuing (resuming) a previous file transfer:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2016-08-31 19:33:33 +01:00
|
|
|
`curl -O -L -C - {{http://example.com/filename}}`
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2016-08-31 19:33:33 +01:00
|
|
|
- Send form-encoded data (POST request of type application/x-www-form-urlencoded):
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2016-08-31 19:33:33 +01:00
|
|
|
`curl -d {{'name=bob'}} {{http://example.com/form}}`
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2016-08-31 19:33:33 +01:00
|
|
|
- Send data, specifying a custom HTTP method, and including an extra header:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2016-08-31 19:33:33 +01:00
|
|
|
`curl -d {{'{"name":"bob"}'}} -X {{PUT}} -H {{'Content-Type: application/json'}} {{http://example.com/users/1234}}`
|
2016-01-12 19:24:22 +00:00
|
|
|
|
2017-01-15 15:47:30 +00:00
|
|
|
- Pass a user name and password for server authentication and show headers info only:
|
2014-03-11 15:01:45 +00:00
|
|
|
|
2017-01-15 15:47:30 +00:00
|
|
|
`curl -u myusername:mypassword -I {{http://example.com}}`
|
2016-01-28 12:12:55 +00:00
|
|
|
|
|
|
|
- Pass client certificate and key for a secure resource:
|
|
|
|
|
2016-08-31 19:33:33 +01:00
|
|
|
`curl -v -key {{key.pem}} -cacert {{ca.pem}} -cert {{client.pem}} -k {{https://example.com}}`
|