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

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!