By default when you do an HTTP GET/POST/PUT/DELETE method request using the cURL command, the output is displayed on the console (standard output)
In order to save the output of a cURL command to a file make use of the -o or --output option followed by the filename and the URL.
Example:% curl -o sample.csv https://code2care.org/sample.csv
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 59 100 59 0 0 621 0 --:--:-- --:--:-- --:--:-- 670
% cat sample.csv
1,Sample-1,100
2,Sample-2,200
3,Sample-3,300
4,Sample-4,400
![cURL Example to save response as external file cURL Example to save response as external file](https://code2care.org/q/save-curl-command-output-to-a-external-file/images/cURL Example to save response as external file.jpg)
Note: Make use of -O (capital letter O) if you want to save the file as that at the remote location.
Example:% curl -O https://code2care.org/sample.csv
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 59 100 59 0 0 612 0 --:--:-- --:--:-- --:--:-- 655
![Save Output to file using cURL Command Save Output to file using cURL Command](https://code2care.org/q/save-curl-command-output-to-a-external-file/images/Save Output to file using cURL Command.jpg)
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to cURL,
- cURL Option to show HTTP Response Status Code
- URL Encode cURL HTTP GET\POST Data with Examples
- Capture cURL Request Output to a File
- Fix: Curl No Match Found Error
- trurl: A new command-line tool for URL parsing and manipulation by cURL Developer
- Send JSON Data as Payload using cURL HTTP POST Request
- cURL: Show Request and Response Headers
- Get cURL command from Chrome Inspect Network HTTP URL
- Save cURL Command Output to a external file
- cURL DELETE Request with Examples
- How to URL Encode Data for a cURL Request Parameters
- cURL Example using IP (IPv4 and IPv6) address and Port
- How to convert a Postman request to cURL Command
- [fix] command not found curl
- How to Pretty Print cURL JSON Output in Terminal
- How to follow redirects in cURL Command Request
- How to pass authorization header using cURL
- cURL -x Use of HTTP Proxy Server Examples
- Downloading Google Chrome using cURL Command
- How to get cURL Command to run in verbose mode?
- List of 28 Protocols supported by cURL with Examples
- Hide cURL Outputs and Errors on Terminal
- cURL -d Option with Examples
- How to show SSL Certificate details using cURL Command
- Perform Basic Authentication using cURL with Examples
More Posts:
- PowerShell ISE Alternative for Mac - Powershell
- TL;DR List of 34+ New Features added to iOS 17 for iPhones - iOS
- How to find Integer MAX and MIN Value in Java - Java
- [fix] Deprecated gradle features were used in this build, making it incompatible with Gradle X.0 - Gradle
- Online Regex Tester Tool - Tools
- How to highlight the current line in Notepad++ - NotepadPlusPlus
- Notepad++ Editor alternatives for macOS - NotepadPlusPlus
- Read file from Windows CMD (Command Line) - Windows