How do I get cURL to not show the progress bar?
curl -s http://google.com > temp.html
works for curl version 7.19.5 on Ubuntu 9.10 (no progress bar). But if for some reason that does not work on your platform, you could always redirect stderr to /dev/null:
curl http://google.com 2>/dev/null > temp.html
Curl with pipe : How to print the error without the progress-meter?
The flag you are looking for is -sS
. From man curl
:
-s, --silent
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.
See also -v, --verbose and --stderr.
Show progress bar in curl without showing response content
The progress bar is sent to stderr. The response is sent to stdout. To redirect and append the response to a file you could use the >>
operator:
while read -r i; do
file="scripts/output.txt"
curl --location --request GET $i -H 'Authorization: ...' >> $file
sleep 5
done < scripts/urls.txt
cURL: How to display progress information while uploading?
This is what I use in one of my build scripts:
curl "${UPLOAD_URL}" \
--progress-bar \
--verbose \
-F build="${BUILD}" \
-F version="${VERSION}" \
-F ipa="@${IPA};type=application/octet-stream" \
-F assets="@-;type=text/xml" \
-F replace="${REPLACE}" \
-A "${CURL_FAKE_USER_AGENT}" \
<<< "${ASSETS}" \
| tee -a "${LOG_FILE}" ; test ${PIPESTATUS[0]} -eq 0
The -F
and -A
options will probably not be of interest to you, but the helpful parts are:
curl "${UPLOAD_URL}" --progress-bar
which tells curl
to show a progress bar (instead of the default 'progress meter') during the upload, and:
| tee -a "${LOG_FILE}" ; test ${PIPESTATUS[0]} -eq 0
which appends the output of the command to a log file and also echo's it to stdout
. The test ${PIPESTATUS[0]} -eq 0
part makes it so that the exit status of this line (which is in a bash script) is the same exit code that the curl
command returned and not the exit status of the tee
command (necessary because tee
is actually the last command being executed in this line, not curl
).
From man curl
:
PROGRESS METER
curl normally displays a progress meter during operations, indicating the
amount of transferred data, transfer speeds and estimated time left, etc.
curl displays this data to the terminal by default, so if you invoke curl
to do an operation and it is about to write data to the terminal, it disables
the progress meter as otherwise it would mess up the output mixing progress
meter and response data.
If you want a progress meter for HTTP POST or PUT requests, you need to
redirect the response output to a file, using shell redirect (>), -o [file]
or similar.
It is not the same case for FTP upload as that operation does not spit out
any response data to the terminal.
If you prefer a progress "bar" instead of the regular meter, -# is your
friend.
OPTIONS
-#, --progress-bar
Make curl display progress as a simple progress bar instead of the
standard, more informational, meter.
How Can I Make Bash Script Using Curl Show Progress Bar
You must make sure to redirect the output to a file instead of stdout. For example with -o
or -O
.
This is because if you don't, curl expects that there might be output sent to the terminal instead and shuts off the progress meter so that the output won't get mixed with the progress meter display on the screen and everything will be all garbled.
When you do a HTTP transfer (even upload), there's an expectation that there will or might be a response body returned as well.
How to configure curl to only show percentage?
Two modifiers might help, although neither are exact: --silent
will suppress all updates and --progress-bar
will show a progress bar only.
Edit: One option to make things easier would be to make a wrapper using Expect to simplify the output to your shell script or whatever is listening to curl.
Decrease the frequency of curl progress updates
No there isn't any such option to curl.
curl will update the progress meter at least once every second but when there's data being transferred it might do it (much) more frequently.
I've added the idea in the curl TODO document!
Related Topics
What's the Difference of Redirect an Output Using ">", "&>", ">&" and "2&>"
How to Concatenate Two Strings to Build a Complete Path
Show Special Characters in Unix While Using 'Less' Command
How Can Objdump Emit Intel Syntax
Using Sed to Split a String with a Delimiter
How to Capture Raw Hid Input on Linux
Backup a Running Docker Container
PDF Compare on Linux Command Line
Fork: Retry: Resource Temporarily Unavailable
Can't Find Out Where Does a Node.Js App Running and Can't Kill It
Linux Shell to Restrict Sftp Users to Their Home Directories
How to Run a Shell Script by Cron Job
What Happens If You Mount to a Non-Empty Mount Point with Fuse
How to Execute an Local Script in Remote Server with Parameters
Is There a Special Restriction on Commands Executed by Cron
Bash Foreach Loop Works Differently When Executed from .Sh File