Using pv to monitor bytes flowing through a pipe, like dd
Sending large files on the command line is often a nerve wrecking experience. Is the file being sent, or am I just going to wait for ever? Fortunately the pv
utility can monitor the number of bytes being sent into a pipe.
Instead of sending your file directly, pipe it to the command from pv
. For example, to write an image file to a disk, do:
pv -tpreb lubuntu-18.10-desktop-amd64.img | sudo dd of=/dev/disk2 bs=1m
The options used are:-t
“Turn the timer on”-p
“Turn the progress bar on”-r
“Turn the rate counter on”-e
“Turn the ETA timer on”-b
“Turn the total byte counter on”
pv
can be used in any pipe. Simply insert pv
in the pipe between other commands. For example, to copy a large file using cat
(a contrived example, but useful for illustrating):
cat lubuntu-18.10-desktop-amd64.iso | pv | cat >> lubuntu-18.10-desktop-amd64.iso.copy
As a sanity check compare the number of byte in the original and the copy using ls -l
:
ls -l lubuntu-18.10-desktop-amd64.iso*-rw-r--r--- 1 xuser xgrp 1694498816 Nov 1 14:03 lubuntu-18.10-desktop-amd64.iso
-rw-r--r-- 1 xuser xgrp 1694498816 Nov 1 17:30 lubuntu-18.10-desktop-amd64.iso.copy
For more options and ways to use pv
, refer to the man page.