Skip to content

Latest commit

 

History

History
79 lines (53 loc) · 1.63 KB

curl.md

File metadata and controls

79 lines (53 loc) · 1.63 KB

Examples

Download a single file

curl <URL>

Download a sequentially numbered files

curl http://example.org/file[1-24].txt

Resume a failed download

curl -C - -o partial_file.zip http://example.com/file.zip

Options

  • -o : Name the output file
  • -O : Download and name it according to its remote name

Auth

  • -u [:]
  • --key : Use private (PEM) key in SSL/SSH request
  • --key-type <(DER|PEM|ENG)>: Specify key format

Net

  • -x :: Add a proxy
  • --limit-rate B: Limit download rate to bytes/sec

HTTP

  • -I: Only fetch headers
  • -i: Include headers in output
  • -H : Add header to request, e.g. curl -H "Foo: bar"
  • -L: Follow 3xx (relocate) responses
  • -v: Verbose, shows request and response headers

Security

  • --cacert : Specify CA-certificate (PEM) file
  • --cert-type <(DER|PEM|ENG)>: Specify cacert format
  • -k: Insecure SSL connection (ignore certificate validation failure)

Extra info

curl -w "foo: %{some_var}\nbar: %{some_other_var}\n" <url>
curl -w @<template_file> <url>

Template:

status:   conn:%{http_connect} http:%{http_code}\n
ip:       %{local_ip}:%{local_port} → %{remote_ip}:%{remote_port} (%{num_connects})\n
redir:    %{url_effective} → %{redirect_url} (%{num_redirects})\n
up:       %{size_request}/%{size_upload}/%{speed_upload}\n
down:     %{size_header}/%{size_download}/%{speed_download}\n
ssl:      %{ssl_verify_result}\n
type:     %{content_type}\n
outfile:  %{filename_effective}\n

get urls listed in files

xargs -n 1 curl -O < list.txt