
To specify the file name, use the -o option (lowercase 'o'). The current directory with the file name photo-1506812574058-fc75fa93fead. So, in the above example, the image will be stored in The -O option tells curl to use everything after the last / in the URLĪs the file name. To download this image using curl, you can run: $ curl -OL The -L option tells curl to follow redirects.įor example, below is an image from Unsplash, the Option is the -remote-name option, which tells curl to store the responseīody in a local file. Practically speaking, wget url is equivalent to curl -OL url. Most Linux distros come with wget built in, but,Ĭonspicuously, OSX does not come with wget.

Downloading a Fileįiles via the command line. The response headers are the lines fromĭate: to x-envoy-upstream-service-time. To make curl print the entire response, including response headers, use the -i flag. When the HTTP request succeeds, curl prints out the HTTP response body. To make an HTTP GET request, you just need to run curl. Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftpįeatures: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL Making an HTTP GET Requestįirst, double-check that you have curl installed by running curl -version. I'll list out the patterns that I find myself using most often withĬurl, using the excellent service as an example.


Unfortunately, the curl docs list 383 supported command-line flags, which makes it difficult to find what you're looking for. Curl supports a wide variety of other protocols,īut, as a Node.js developer, you'll most likely use it to make HTTP Curl is a popular command line tool often used for
