Skip to main content

Ivan Pavlov's Library tagged tutorial   View Popular

04 Feb 09

A Unix Utility You Should Know About: Pipe Viewer

  • Another similar example would be to pack the whole directory of files into a compressed tarball:


    $ tar -czf - . | pv > out.tgz
    117MB 0:00:55 [2.7MB/s] [> ]

    In this example pv shows just the output rate of “tar -czf” command. Not very interesting and it does not provide information about how much data is left. We need to provide the total size of data we are tarring to pv, it’s done this way:


    $ tar -cf - . | pv -s $(du -sb . | awk '{print $1}') | gzip > out.tgz
    253MB 0:00:05 [46.7MB/s] [> ] 1% ETA 0:04:49

    What happens here is we tell tar to create “-c” an archive of all files in current dir “.” (recursively) and output the data to stdout “-f -”. Next we specify the size “-s” to pv of all files in current dir. The “du -sb . | awk ‘{print $1}’” returns number of bytes in current dir, and it gets fed as “-s” parameter to pv. Next we gzip the whole content and output the result to out.tgz file. This way “pv” knows how much data is still left to be processed and shows us that it will totally take 4 mins 49 secs to finish.

1 - 5 of 5
Showing 20 items per page

Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »

Join Diigo