Monday, September 24, 2012

News: Unusual commands in linux : pv

Today I will speak about pv command.
Pipe viewer - pv is a terminal-based tool for monitoring the progress of data through a pipeline written by Andrew Wood
To install pv on Fedora or CentOS do this:
$ sudo yum install pv
You can read the man file to get more help:
man pv
The result is:
       pv - monitor the progress of data through a pipe

       pv [OPTION] [FILE]...
       pv [-h|-V]

       pv  allows  a  user  to see the progress of data through a pipeline, by
       giving information such as time  elapsed,  percentage  completed  (with
       progress  bar),  current  throughput  rate, total data transferred, and

       To use it, insert it in a pipeline  between  two  processes,  with  the
       appropriate  options.  Its standard input will be passed through to its
       standard output and progress will be shown on standard error.
Let's see some examples.
You can get precise time how long it will take.
$ pv | python 
 737B 0:00:00 [86.9kB/s] [==================================>] 100%
You can see how fast the computer reads from /dev/zero.
$ pv /dev/zero > /dev/null
1.1GB 0:00:05 [   2GB/s] [    <=>                                            ]
You can use the dialog to show a progress bar.
To do this you need to use -n arg.
$ (pv -n /dev/zero > /dev/null) 2>&1 | dialog --gauge "Please wait" 10 70 0