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