Counting down with ‘pv’

Jul 16, 2009 • alan

Here’s a neat tool.

Ever start some long task, and wonder how much longer it has to go? There’s a small utility called pv (short for “pipe viewer”) that counts time and bytes through a pipe, and it shows a nice progress bar.

Here’s how I used it to watch a very large file being compressed (note the use of the most excellent lzma compression utility.

$ pv < winxp.vdi | lzma > winxp.vdi.lzma
1.79GB 0:21:50 [1.49MB/s] [===>          ] 10% ETA 3:11:02

Note that if I had used a different pipe notation, pv would not have been able to read the input file size, and therefore it could not make estimates of remaining time. So instead, it shows you the “Knight Rider” scanning eye for progress.

$ cat winxp.vdi | pv | lzma > winxp.vdi.lzma
5.48MB 0:00:04 [1.27MB/s] [  <=>         ]

Nice tool. Thanks, Andrew!