Capture cURL Request Output to a File

If you want to execute a cURL command on the Terminal and want to capture the result of the request to a file, you can do that in the following ways.

Option 1: Using --output (-o) flag

curl -o output.txt


curl --output output.txt
cURL Request Output to a file using -o option Example

Option 2: Redirect Output using > redirection operator

curl > curl_output.txt

Use >> if you want to append to the same file.

curl >> curl_output.txt
curl output to file using

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:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap