2

Notice that this question is distinctly different from How do I get cURL to not show the progress bar? though a valid answer to this question would likely suffice this comment on that other question.

I have a script that is logging cURL's stderr to a file. We'll use this as an example:

curl -Lo /dev/null stackoverflow.com 2>/tmp/foo

When I inspect that file, it looks like this:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
^M  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0^M100   143  100   143    0     0   1190      0 --:--:-- --:--:-- --:--:--  1191
^M 97  244k   97  239k    0     0   688k      0 --:--:-- --:--:-- --:--:--  688k^M100  244k  100  244k    0     0   701k      0 --:--:-- --:--:-- --:--:-- 4974k

And that's total garbage to me. I want the statistics without the animated progress bar. I can parse it out with some standard unix tools. However, I'm thinking maybe some combination of arguments and/or termcap/terminfo may also work.

Please advise.


This simple post processing would work because it's not animated:

head -n2 /tmp/foo; tail -n1 /tmp/foo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  245k  100  245k    0     0   393k      0 --:--:-- --:--:-- --:--:--  393k
Bruno Bronosky
  • 60,791
  • 11
  • 147
  • 135

1 Answers1

0

If I don't get any better suggestions, I'm going to settle for this:

$ curl -Lo /dev/null --stderr >(awk 'END {print "Downloaded", $2, "of", $4, "at", $7"bps"}' >/tmp/foo) stackoverflow.com
$ cat /tmp/foo
Downloaded 245k of 245k at 472kbps
Bruno Bronosky
  • 60,791
  • 11
  • 147
  • 135