2

When I run

curl example.com > example.html

on the terminal, I get the progress meter as follows

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  1256  100  1256    0     0   1950      0 --:--:-- --:--:-- --:--:--  1947
100  1256  100  1256    0     0   1950      0 --:--:-- --:--:-- --:--:--  1947

According to https://curl.se/docs/manpage.html it is necessary to redirect the curl stdout to a file in order to have this message displayed. "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 (>), --output or similar." If I run

curl example.com 2> progress.txt

there is no data in progress.txt. Therefore I need to run

curl example.com > example.html 2> progress.txt

How can I access the progress meter without redirecting the curl stdout to a file?

2 Answers 2

1

If you pipe the data to another program, you’ll get the progress meter. A basic

curl example.com | cat

works, but with longer results you’ll run into the issue mentioned in the documentation:

it disables the progress meter as otherwise it would mess up the output mixing progress meter and response data

To avoid that, use sponge (from moreutils, available in most distributions):

curl example.com | sponge
0

In my case, this workaround worked perfectly fine, displaying the whole response after the request is done:

curl -o /tmp/file https://example.com && cat /tmp/file

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.