Wednesday, January 31, 2018

cURL - client for URLs

Have been hearing about the tool cURL but never looked into its expansion - its client for URL!

Yes, it deals with URL and hence can also be called as "see URL"

cURL Commands in action:

1. To display content of the site page in your terminal

          curl http://cmshiyas.com

2. Save the output of an URL to a file
   
         curl -o website http://cmshiyas.com

this command saves the output of the site page to the file named website in the current working directory

  • -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 http://cmshiyas.com/index.html

3. Download files

          curl -o archive.zip http://cmshiyas.com/ShiyasFullStackDeveloper.docx

download multiple files

          curl -o archive.zip http://cmshiyas.com/ShiyasFullStackDeveloper.docx -o http://cmshiyas.com/ShiyasFullStackDeveloperNew.docx

to download files securely via SSH

          $ curl -u user ftp://cmshiyas.com

4. Get http header information

           $ curl -I https://google.com

5. Access FTP server

download a file via FTP

                $ curl ftp://ftp.cmshiyas.com/ShiyasFullStackDeveloper.docx --user username:password

upload  a file to server

                $ curl -T file.zip ftp://ftp.cmshiyas.com/ --user username:password

to check cURL man page

               man cURL

Reference:
https://curl.haxx.se/docs/faq.html#What_is_cURL
https://www.rosehosting.com/blog/curl-command-examples/
https://www.thegeekstuff.com/2012/04/curl-examples/

No comments:

Post a Comment