1. Download a Single File
$ curl http://www.centos.org

2. Save the cURL Output to a file
-o (lowercase o) the result will be saved in the filename provided in the command line
-O (uppercase O) the filename in the URL will be taken and it will be used as the filename to store the result

$ curl -o mygettext.html http://www.gnu.org/software/gettext/manual/gettext.html
$ curl -O http://www.gnu.org/software/gettext/manual/gettext.html

3. Fetch Multiple Files at a time
$ curl -O URL1 -O URL2

4. Follow HTTP Location Headers with -L option
$ curl -L http://www.google.com

5. Continue/Resume a Previous Download
curl -C - -O http://www.gnu.org/software/gettext/manual/gettext.html

6. Limit the Rate of Data Transfer
$ curl --limit-rate 1000B -O http://www.gnu.org/software/gettext/manual/gettext.html

7. Download a file only if it is modified before/after the given time
$ curl -z 21-Dec-11 http://www.example.com/yy.html
$ curl -z -21-Dec-11 http://www.example.com/yy.html

8. Pass HTTP Authentication in cURL
$ curl -u username:password URL

9. Download Files from FTP server
$ curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/xss.php
$ curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/

10. List/Download using Ranges
$ curl ftp://ftp.uk.debian.org/debian/pool/main/[a-z]/

11. Upload Files to FTP Server
$ curl -u ftpuser:ftppass -T myfile.txt ftp://ftp.testserver.com
$ curl -u ftpuser:ftppass -T "{file1,file2}" ftp://ftp.testserver.com
$ curl -u ftpuser:ftppass -T - ftp://ftp.testserver.com/myfile_1.txt

12. More Information using Verbose and Trace Option
curl -v http://google.co.in

13. Get Definition of a Word using DICT Protocol
$ curl dict://dict.org/d:ravenous:english

14. Use Proxy to Download a File
$ curl -x proxysever.test.com:3128 http://google.co.in

15. Send Mail using SMTP Protocol
$ curl --mail-from blah@test.com --mail-rcpt foo@test.com smtp://mailserver.com

Advertisements