Skip to content

Monitor the progress of Unix commands with Pipe Viewer (pv)

I just stumbled across the following post while trying to find out how to copy text from VIM using XSel without losing the selected text. It introduces Pipe Viewer, a Unix utility which is a kind of cat with a progress bar.

I emerged it (it’s in Gentoo (Debian too)) and it works very simple, but allows you to do cooler, more complicated things.

# pv emerge.log |gzip >emerge.log.gz
1.24MB 0:00:00 [1.76MB/s] [================>] 100%  
$ pv -cN source access_log | gzip | pv -cN gzip > access_log.gz
   source: 28.7MB 0:00:00 [32.2MB/s] [=====>] 100%            
     gzip: 2.27MB 0:00:00 [2.54MB/s] [ <=>  ]

The first example is easy enough to understand when you mentally substitute pv with cat. The second example is much cooler. It uses the -N flag to make named groups and the -c flag to make sure that the output for these groups doesn’t get garbled.

Read Peteris Krumins’ article for more cool uses of Pipe Viewer.


No Comments ( Add comment / trackback )

Post a comment

(required)
(required)

Your email is never published nor shared.

(optional)
Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>