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

Example:
curl -o output.txt https://code2care.org

or,

curl --output output.txt https://code2care.org
cURL Request Output to a file using -o option Example


Option 2: Redirect Output using > redirection operator

Example:
curl https://code2care.org > curl_output.txt

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

curl https://code2care.org >> 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) is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. 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

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