The Advent of Void: Day 16: pv
A tool with many uses is pv(1), the ‘pipe viewer’. Essentially, you can put it between any pipe and you’ll see statistics on its throughput.
For example, we can measure the speed of
% pv < /dev/urandom > /dev/null 168MiB 0:00:01 [ 167MiB/s] [<=> ]
Or look how fast we can extract a tar.xz file:
% xzcat big.xz | pv | tar xf -
Or copy a whole disk to a remote host, with a progress bar:
# dd if=/dev/sdb | pv | ssh me@remote dd of=/dev/sdc
% find /tmp -name '*.png' | pv -l | xargs -P4 -n1 pngcrush -ow
(Or even better, use
find -print0 and
pv also can limit the bandwidth, which can be useful if you
want to limit transfer rates to lower strain on the system, for example,
and buffer the input, which is useful to ensure a consistent write rate.