These curl recipes show you how to save the response from a curl request to a file. By default, curl prints the response to screen. To make it save the response to a file, use the -o file command line option.

Save the Response from a GET Request to a File

curl -o response.txt https://google.com?q=kitties

In this recipe, curl uses the -o response.txt command line option to save the response from a GET request that it makes to https://google.com?q=kitties to a file with filename response.txt.

Use the Last Fragment of a URL as the Filename

curl -O https://catonmat.net/ftp/digg.pm

This recipe uses the -O argument that forces curl to use the last part of the URL as the filename. In this case, the URL is https://catonmat.net/ftp/digg.pm and the last part of the URL is digg.pm. As a result, curl will create a new file digg.pm and put the response body there.

Created by Browserling

These curl recipes were written down by me and my team at Browserling. We use recipes like this every day to get things done and improve Browserling. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!

Secret message: If you love my curl recipe, then I love you, too! Use coupon code CURLLING to get a discount at my company Browserling.