pv
2 min read
pv (Pipe Viewer) monitors the progress of data flowing through a pipeline. Insert it anywhere between two processes and it shows elapsed time, throughput, bytes transferred, a progress bar and an ETA — on stderr, so the data passes through untouched.
Usage
Use it like cat to get a progress bar on a file (size is known, so you get a percentage and ETA):
shell
pv big.iso > /dev/sdX
pv backup.tar.gz | tar xzf -
Drop it into the middle of a pipeline:
shell
tar cf - dir/ | pv | zstd > dir.tar.zst
When reading from a pipe, the total size is unknown — pass it with -s to get a real percentage:
shell
tar cf - dir/ | pv -s $(du -sb dir/ | cut -f1) | gzip > dir.tar.gz
Watch compressed vs. uncompressed rates side by side with named, stacked bars (-c uses cursor positioning so multiple instances don't clobber each other):
shell
pv -cN raw big.log | gzip | pv -cN gz > big.log.gz
Rate-limit a transfer (e.g. to not saturate a link):
shell
pv -L 2m file | ssh host 'cat > file'
Count lines instead of bytes:
shell
some-generator | pv -l > out.txt
Attach to an already-running process and watch its open file descriptors (Linux):
shell
pv -d $(pidof cp)
Options
| Option | Description |
|---|---|
-p, --progress | Show progress bar |
-t, --timer | Show elapsed time |
-e, --eta | Show estimated time remaining |
-r, --rate | Show current transfer rate |
-a, --average-rate | Show average transfer rate |
-b, --bytes | Show total bytes transferred |
-n, --numeric | Print integer percentages, one per line (for piping into e.g. dialog --gauge) |
-q, --quiet | No output (useful with -L for pure rate limiting) |
-s, --size SIZE | Assume total size is SIZE (accepts suffixes like 1g) |
-l, --line-mode | Count lines instead of bytes |
-N, --name NAME | Prefix output with a name |
-c, --cursor | Use cursor positioning escapes (for multiple pvs in one pipeline) |
-L, --rate-limit R | Limit transfer to R bytes per second |
-B, --buffer-size | Use a transfer buffer of the given size |
-d, --watchfd PID | Watch file descriptors of process PID instead of transferring data |
-R, --remote PID | Change the options of an already-running pv (e.g. raise its rate limit on the fly) |