These curl recipes show you how to make curl silent so that it doesn't print progress bar, errors, and other output that can get in the way. To do that, use the
-s argument. To also hide the response, use the
-o /dev/null to discard the output (
-o NUL on Windows).
Hide Errors and Progress Bar (but Print Response)
curl -s https://catonmat.net
In this recipe, curl uses the
-s argument that hides all errors and the progress bar. If the request succeeds, then curl will still print the response body. If there was an error, then the only way to tell what it was is to check the exit code of the curl process. See the next recipe to see how to make dead silent curl requests.
Make Curl Dead Silent
curl -s -o /dev/null https://google.com
In this recipe, we combine the
-s option that we used in the previous recipe with the
-o /dev/null option. The combination of both of these options makes curl absolutely silent. The only way to tell if it succeeded or failed is to check the return code of the curl program. If it's zero, then curl succeeded, otherwise it failed.
Make Curl Dead Silent (but Print the Error)
curl -S -s -o /dev/null https://google.com
This recipe adds the
-S command line argument to the mix. When combined with the
-s argument, it tells curl to be silent, except when there is an error. In that case, print the error. This recipe is useful when you want curl to be silent but still want to know why it failed.
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.