pv – Pipe viewer

pv – Pipe viewer is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion.

Here there are some example of using this tool:

Example 1: Copying file
$ pv file > /path/to/dir/file

Example 2: Decompess file
$ pv data.tar.bz2 |tar xjf –

Example 3: Backing up a PostgreSQL database
$ pg_dump data | pv -t | bzip2 > data.bz2

Example 4: File remote copy
# on computer foo, with IP address 192.168.0.1
$ tar -cf – /path/to/dir | pv | nc -l -p 6666 -q 5

# on computer bar
$ nc 192.168.0.1 6666 | pv | tar -xf –

Example 5: Switching a compress file format from bzip2 to zip
$ pv -cN source < file.tar.bz2 | bzcat | pv -cN bzcat | gzip -9 | pv -cN gzip > file.tar.gz

Example 6: Generate a compressed archive of the current directory
$ (tar cvf – . 2>log | pv -n -s `du -sb . | awk ‘{ print $1 }’` | gzip > out.tgz) 2>&1 | dialog –title “Archiving” –gauge ‘Progress’ 9 60

And there are also, many useful tips with pv, for more usage please refer to manual pages.

If you want to get pv on Debian or Debian based system such as Ubuntu do the following:
$ sudo aptitude install pv

If you’re on Fedora do:
$ sudo yum install pv

pv – Pipe viewer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s