Curl is a program which allows you to view the contents of a file on a remote PC, to GET a file from a remote PC, or to POST a file to a remote PC. For example, the curl command without any option followed by a URL will display the contents of the target file. For example, the following will GET the contents of the index.html file.
~]# curl http://www.example/index.html <html> <body> Hello World </body> </html>
Redirection can be used to transfer the contents of the target file to a file on the local PC. For example, to transfer the contents of the index.html file to local.file.
~]# curl http://www.example/index.html > local.file
Similarly, the -o option followed by the target file and then the URL will transfer the target file to the local PC.
curl -o index.html http://www.example/
GET / POST / PUT / DELETE
The -X or --request option can be used to specify the type of request you want to use, such as GET, POST, PUT, or DELETE. In this example, a request is submitted to the web server with ID 12345 and a delete request. The web server or application logic needs to be setup to understand how to process this type of request.
~]# curl -X DELETE http://www.example/id=12345
If the resource requires authentication, the --basic and -u options can be used to authenticate.
~]# curl --basic -u 'username:password' http://www.example/secure.html