I am a new Ubuntu Linux user. I am writing a shell script and using the curl command to grab URL output using curl https://example.com/data/api/$key/hash.html. However, the curl command is outputting complete progress information that my script does not need it. How can I get curl command not to show the progress bar output? How can I hide curl command output? Is there is a simple way for silencing curl’s progress output on an Ubuntu Linux desktop?
Introduction: cUrl is both an application library and command for downloading files or performing requests on the Web. The curl command works on Linux, Windows, macOS, *BSD and Unix-like system. This page shows how to hide progress bar output on a Linux or Unix-like system when using the curl command.
curl hide progress bar output when using shell scripts
The procedure to hide curl progress bar is to pass the -s or --silent option to the curl command:
- Open the terminal app
- Type the command: curl -s https://sxi.io/ > /tmp/output.html
- Verify it with the cat command: cat /tmp/output.html
Let us see all commands and some examples in details.
How can I get cURL not show the progress bar on Linux
How to silencing curl command’s progress output
$ curl -s https://sxi.io/ > /tmp/output.html
$ curl --silent https://sxi.io/ > /tmp/output.html
You can use the grep command or egrep command as follows too:
$ curl -s https://www.kernel.org/ | grep -A 2 '<td id="latest_button">'
Understanding the -s and -S options
From the curl man page:
The -s or --silent option act as silent or quiet mode. Don’t show progress meter or error messages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it.
Use -S, --show-error in addition to this option to disable progress meter but still show error messages.
The following command will silence the progress output without silencing real errors:
$ curl -sS https://www.example.com/foo/bar.cgi > /tmp/out.txt
$ curl -sS https://sxi.io/ > /dev/null
Eliminating progress bar on an older version of curl running on Unix-like system
If you are using an older version of curl and cannot update curl that has -s option, try:
$ curl https://www.nixcraft.com/ 2>/dev/null > /tmp/nix.html
$ curl https://www.nixcraft.com/ 2>/dev/null | grep '<title>'
You just learned how to eliminating curl command’s progress bar output when using with shell scripts. For more info see curl command man page.