views:

902

answers:

3

Hello all,

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

+1  A: 

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
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
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
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
+1  A: 

You might want to try the -# option.

It shows a simple progress bar and percentage downloaded.

Nick Presta
+2  A: 

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