How to Run curl in Silent Mode
When transferring data with the curl command-line tool,
the terminal by default displays a progress meter and various status
updates. This article provides a quick guide on how to use the silent
mode option in curl to suppress this default progress and
error output, making it ideal for scripts and clean terminal logs.
To make curl run in silent mode, you use the
-s or
--silent command-line option.
When this option is active, curl will not show the
progress meter, upload/download speeds, or error messages. It will only
output the requested data (or write it to a file if specified).
Basic Syntax
To use silent mode, simply append -s to your
curl command:
curl -s https://api.github.comCombining Silent Mode with Error Reporting
One drawback of using -s alone is that it also hides
critical error messages (such as network failures or invalid URLs). To
silence the progress meter but still display errors if the command
fails, combine the silent option with the
-S (or
--show-error) option:
curl -sS https://api.github.comUsing -sS is the recommended best practice when writing
bash scripts, as it keeps the output clean during successful runs while
still allowing you to debug issues when things go wrong.
Saving Output Silently
If you want to download a file silently and save it directly to a
local file, combine the silent flags with the -o (output)
flag:
curl -sS -o logo.png https://example.com/logo.pngThis command runs in the background of your terminal without
cluttering your screen, writing the downloaded file directly to
logo.png and only alerting you if an error occurs.