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).

user123456
  • 4,758
  • 11
  • 52
  • 78

1 Answers1

16

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.

Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501