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:10:00New to Newsletter — Earn With Paid Subscriptions —» Ileana Pîrgaru
20:01:19Mi-a ieșit un slalom impresionant pe pasaj și bulevard —» .:EU:.
19:58:21Protest al sindicatului din sistemul energetic —» Curaj.TV | Media alternativă
19:39:17Pledoarie din trafic pentru transport alternativ, sănătos —» Curaj.TV | Media alternativă
19:07:29+16 Armata de pe plai e pregătită de sărbătoare (limbaj vulgar!) —» Curaj.TV | Media alternativă
19:02:52Șantier mortal in centrul capitalei —» Curaj.TV | Media alternativă
19:01:33Săpături arheologice cu escavatorul?! —» Curaj.TV | Media alternativă
17:39:33Nu se bucură că fosta nevastă ar putea fi condamnată —» Curaj.TV | Media alternativă
13:10:00How Yarnnakarn Ceramics Uses WordPress.com to Expand Their Business —» Adăpostul gîndurilor nerevendicate | If I enjoy the hatred of life, I do not hate life, I enjoy i
09:48:46atenție, atenție: portalu s-o deschis —» Portalu
17:15:00Top 6 alimente care conține substanțe cancerogene. —» Blog de Cultura
16:59:00Care este diferența dintre un psiholog, psihoterapeut și un psihiatru? —» Blog de Cultura
16:56:37Mega Protestul de astăzi al profesorilor în București —» Curaj.TV | Media alternativă
15:00:00Concept to Creation: Custom Theme Designs Just Got Easier —» ada rosu
14:54:29Romanul „Montana” de Alexandru Popescu în continuă discuție —» BiblioCity
11:17:17Zilele Bibliotecii, 2023. Sinteză —» Biblioteca de Arte 'Tudor Arghezi'
09:39:11Tutunul și impactul asupra performanței școlare și profesionale —» BiblioCity
15:31:25Zilele Onisifor Ghibu la Biblioteca „Onisifor Ghibu” —» BiblioCity
13:57:00DIN COSMOGRAME —» Leo Butnaru
21:00:04Au băut nişte ofiţeri în unitate, se poate?! —» Curaj.TV | Media alternativă
11:43:43A luat foc un clopot de gunoi lîngă Gara de Nord —» Curaj.TV | Media alternativă
11:41:12Mașină de poliție pe trotuar, cu motorul pornit —» Curaj.TV | Media alternativă