Linux Pipe Viewer (pv)

From Thomas-Krenn-Wiki
Jump to navigation Jump to search

The command line tool pv (Pipe Viewer) can be added between two processes to visualize the data flow. Everything that pv receives at the standard input (stdin) is output again at the standard output (stout).The progress itself is output to standard error (stderr).

This tool is not installed as standard in most distributions. Under Debian/Ubuntu, it can be installed with apt-get install pv.

The following examples explain the usage:

Progress when unpacking with bzip2

This example extracts the Linux kernel into the current directory, which is available as a tar archive compressed with bzip2.

$ pv linux-3.1.5.tar.bz2 | bzip2 -d | tar x
23.6MB 0:00:08 [3.12MB/s] [=========>                          ] 30% ETA 0:00:18

Progress when unpacking with gzip

The following command unpacks the home directory in a gzip compressed tar-archive.

$ tar cf - /home/ | pv | gzip > home.tar.gz
tar: Removing leading `/' from member names
52.3MB 0:00:02 [24.8MB/s] [     <=>           

Generate ISO image with progress display

The following example generates an ISO image of the inserted CD and shows the progress.

dd if=/dev/cdrom | pv --size 700M | dd of=test.iso
436MB 0:01:10 [7.6MB/s] [============================================>                            ] 62% ETA 0:00:56

Something similar can also be achieved with a special kill signal (see Create an ISO Image from a source CD or DVD under Linux).

Reading /dev/zero

This command shows how fast the /dev/zero computer can read.

pv /dev/zero > /dev/null
40GB 0:00:04 [  10GB/s] [      <=>                                                                                ]

The following complex example is listed in the Manpage with the following ironic comment:

Frequent use of this third form is not recommended as it may cause the programmer to overheat.

              (tar cf - . \
               | pv -n -s $(du -sb . | awk '{print $1}') \
               | gzip -9 > out.tgz) 2>&1 \
              | dialog --gauge 'Progress' 7 70

Further links


Author: Christoph Mitasch

Christoph Mitasch works in the Web Operations & Knowledge Transfer team at Thomas-Krenn. He is responsible for the maintenance and further development of the webshop infrastructure. After an internship at IBM Linz, he finished his diploma studies "Computer- and Media-Security" at FH Hagenberg. He lives near Linz and beside working, he is an enthusiastic marathon runner and juggler, where he hold various world-records.


Translator: Alina Ranzinger

Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department.


Related articles

Apache bandwidth limitation under Debian
Creation of Windows 11 USB installation stick under Linux
Ps and pstree