20

Is there an option for the curl command to show only a percentage output to shell rather than all of this, for example:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12.4M  100 12.4M    0     0  4489k      0  0:00:02  0:00:02 --:--:-- 4653k

Maybe there is a flag I can set? If not, pipe it somehow through a regular expression to show me a continuous update of the percentage only?

Thanks all

2240
  • 1,547
  • 2
  • 12
  • 30
Abs
  • 56,052
  • 101
  • 275
  • 409
  • If you are parsing the value's sent, what are you using to do so? You might consider using http://en.wikipedia.org/wiki/Expect to create a wrapper utility: hide all the parsing complexity in the Expect script and just output what you need. – Godeke Jul 15 '09 at 16:26
  • I am using PHP's popen function and storing the output into a text file. I am having a look at your reference link, it looks quite complicated! – Abs Jul 15 '09 at 16:46

3 Answers3

29

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.

Godeke
  • 16,131
  • 4
  • 62
  • 86
11

Does the parameter -# solve your problem?

-#/--progress-bar

Make curl display progress information as a progress bar instead of the default statistics.

From here.

schnaader
  • 49,103
  • 10
  • 104
  • 136
  • That's looks interesting but I am going to be capturing the percentage, is there a way for it not to be so interactive? – Abs Jul 15 '09 at 15:43
  • I don't have CURL installed to test it, but I think this displays some type of bar and the percentage in the middle (or somewhere else). Can you pipe this and filter the numbers out to get the percentage? – schnaader Jul 15 '09 at 15:53
  • My command line skills isn't exactly good! But I tried piping the output to this " | grep -o '[0-9]*'" - however nothing came up. Even if it did, would it do this continuously as the number changed? Maybe a loop needs to be used? – Abs Jul 15 '09 at 16:05
10

You might want to try the -# option.

It shows a simple progress bar and percentage downloaded.

Nick Presta
  • 28,134
  • 6
  • 57
  • 76