16

If myfile is increasing over time, I can get the number of line per second using

tail -f | pv -lr > /dev/null

It gives instantaneous speed, not average.

How can I get the average speed (i.e the integral of the speed function v(t) over the monitoring time).

15

With pv 1.2.0 (December 2010) and above, it's with the -a option:

Here with both current and average, line-based:

$ find / 2> /dev/null | pv -ral > /dev/null
[6.28k/s] [70.1k/s]

With 1.3.8 (October 2012) and newer, you can also use -F/--format with %a:

$ find / 2> /dev/null | pv -lF 'current: %r, average: %a'  > /dev/null
current: [4.66k/s], average: [ 218k/s]

Note that tail -f starts by dumping the last 10 lines of the file. Use tail -n 0 -f file | pv -la to avoid that bias in your average speed calculation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.