pv: Progress Bar for md5sum et al.

Tools that know they will take a long time often come with a built-in progress indicator, but there are other utilities on Linux that often leave the user frustratedly tapping their fingers, wondering how much longer they will have to wait.

Luckily, there is a nifty little tool called pv that will donate a progress bar to any program that can read from standard input or a pipe. pv probably stands for pipe viewer.

1. Simple example: figure out how long an md5sum will take:

pv eternal.avi |md5sum

will display something like

96.5MB 0:00:05 [25.3MB/s] [=======>                                    ]  9% ETA 0:00:48


  • pv reads from file and prints to stdout.
  • md5sum reads from stdin.
  • pv outputs the progress bar to stderr so as not to interfere with the piped data. See the man page for ways to customize pv’s output.
  • since the bottleneck of such an operation is the media you’re reading from, not the CPU, there will be no noticeable overhead.

2. Complex example: add a progress bar to tar/bzip2 compression/decompression:

tar cf - mydir | pv -n -s $(du -sb mydir | awk ‘{print $1}’) | bzip2 >mydir.tar.bz2


  • this example is adapted from the pv man page.
  • the -n switch makes pv output only percentage values.
  • no file is passed to pv, so it reads from stdin (piped to the output of tar).
  • on a system with good cache and enough memory, doing the extra du -s mydir shouldn’t hurt much, since tar will go through the entire directory anyway.

Now let’s decompress it:

pv mydir.tar.bz2 |tar xjf -

By now you realize how awesome this is.

3. Fun example: measure /dev/null throughput:

pv /dev/zero >/dev/null

is close to 3.3GB/s on my 3-year-old system.


  • this is not a benchmark ™.
  • pv can’t know the size of its input in this case (infinity), so it obviously can’t display an ETA.

pv is a brilliant example of the UNIX philosophy: simple puzzle pieces combining to create useful results. A couple of last-word remarks:

  • There is apparently a very similar tool called cpipe.
  • There are, unfortunately, programs for which you will not be able to use pv. One example is dpkg, which apparently tries seeking in its input, thus failing to work with pipes.
  • Thanks to my boss for pointing me to this awesome tool.
Posted in Linux, Shell, Technology   Tagged: bzip, bzip2, compression, decompression, md5, md5 sum, md5sum, pipe, progress, progress bar, pv, tar, throughput, tool, trick, unzip, zip   

2009-02-05 00:00:00


Ultimele 25 posturi adăugate

13:29:40Vinerea Neagră pe shop.cartier.md. Carte la jumătate de preț —» Gheorghe Erizanu
13:19:11Două cărți pe care să le citești până la Crăciun —» Sunt MAMĂ!
08:50:40Oamenii —» Viata pe Tinder – Viata amoroasa pe Tinder
08:19:15Săptămâna în care ACUM a predat cheile Kremlinului —» Un PUNCT din .FR
07:43:41Chain Link Fence Ideas —» Andrei Fornea
07:40:02Dinette Table And Chairs —» Andrei Fornea
07:21:49Veneţia a fost inundată din nou. Monumente istorice, aflate în patrimoniul UNESCO, sunt în pericol —» Elena Robu
05:26:08CA(TREN)* —» Andrei LANGA. Blogul personal
20:51:04Olga Roman, amica lui Filat, a fost reținută în Dubai! —» un alt blog
20:33:47CA(TREN)* —» Andrei LANGA. Blogul personal
19:17:52CRUCIFIX* —» Andrei LANGA. Blogul personal
18:41:24Discuție la Microfonul Liber referitor la conducerea trecută și prezentă —» Curaj.TV | Media alternativă
18:38:33Poliția din Cricova încearcă să-i cenzureze cazul —» Curaj.TV | Media alternativă
16:37:32Classic Beer Battered Fish and Mushy Peas —» ajna-blogging-press
11:34:19Poliția e complice cu soțul/tatăl – agresor?! —» Curaj.TV | Media alternativă
11:15:54Алексaндр Леонидович Чижевский - учёный, биофизик, философ, поэт, художник. —» Удивительные истории из жизни великих людей
10:27:32Vedere dinspre stînga – A fost coaliția, nu mai e coaliția —» Curaj.TV | Media alternativă
09:24:38Păreri —» Primul meu blog
05:36:23Solid Wood Chairs —» Andrei Fornea
04:48:54Ziua a treia de creație | Creația Uimitoare a lui Dumnezeu —» Moldova Creștină
01:52:15Kitchen Floor Ideas Pictures —» Andrei Fornea
19:15:01De la România Mare la România democratică —» Curaj.TV | Media alternativă
18:33:07Pairing Wine and Cheese: The Ultimate Guide —» ajna-blogging-press
18:27:10Doggy style —» APort | "Pentru un român care știe citi, cel mai greu lucru e să nu scrie." I.L. Carag
17:44:46O vinzatoare face evaziune fiscala la bauturi spirtoase si placinte —» Curaj.TV | Media alternativă