Ivan Pavlov's Library tagged → View Popular
A Unix Utility You Should Know About: Pipe Viewer
pv < /dev/zero > /dev/null
-
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:49What 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.
Sponsored Links
Top Contributors
Groups interested in tutorial
-
Poster Ideas
photoshop Tutorials , Ideas...
Items: 9 | Visits: 220
Created by: marco flores
-
Screencast/Tutorial Software
Items: 13 | Visits: 208
Created by: Darren Draper
-
Tutorials
Une liste dédiée aux tutori...
Items: 7 | Visits: 93
Created by: DELBAR Edouard
Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »
Join Diigo
