Basic Usage
If you only need to download a file, you can use the following command:
bashcurl -O [URL]
The -O option instructs curl to save the downloaded file using the filename specified by the server.
Example:
Suppose we want to download an image file from https://example.com/sample.jpg, we can use:
bashcurl -O https://example.com/sample.jpg
Specify Filename
If you want to specify a different filename during download, you can use the -o option:
bashcurl -o myfilename.jpg [URL]
Example:
Suppose we want to download the same image but save it as newname.jpg:
bashcurl -o newname.jpg https://example.com/sample.jpg
Advanced Usage
Download from Authenticated Sites
If the file you want to download is on a server requiring authentication, curl can handle this. Use the -u option to provide the username and password:
bashcurl -u username:password -O [URL]
Example: Suppose we want to download an authenticated file:
bashcurl -u user123:passwd123 -O https://secure.example.com/protected.zip
Increase Download Speed
If your connection allows, you can attempt to use curl's multi-threaded download options, such as running multiple curl instances to download different parts of the file in parallel. Note that this is not a built-in feature of curl but can be achieved with some scripts.
Summary
curl is a very flexible tool that can be used to download various types of files. Its basic functionality is sufficient for most download needs, while its advanced features can handle more complex scenarios, such as authentication or custom HTTP headers. By combining different options and parameters, you can make curl adapt to almost any download requirement.