Lei Mao bio photo

Lei Mao

Machine Learning, Artificial Intelligence, Computer Science.

Twitter Facebook LinkedIn GitHub   G. Scholar E-Mail RSS

Introduction

Sometimes, we will have to deal with large file copy and compression and decompression. These operations will take very long time and we would like to track the their progresses.


Linux has a tool called pv, namely pipe viewer, that allows showing the progress bar of file copy, compression, and decompression. In this blog post, I would like to show its usage quickly.

Prerequisites

$ sudo apt update
$ sudo apt install pv pigz

Note that pigz could improve the compression and decompression performance significantly.

Usage

Copy File

$ pv source/data.tar.gz > target/data.tar.gz
142GiB 0:13:53 [ 178MiB/s] [==============================>] 100%  

Tape Archive Decompression

$ pv source/data.tar.gz | tar xf - --use-compress-program="pigz -dk -p8" -C target/
142GiB 0:09:40 [ 250MiB/s] [==============================>] 100%  

Tape Archive Compression

$ tar -cf - --use-compress-program="pigz -k -p8" source/data/ | pv -s $(du -sb data/ | awk '{print $1}')  > target/data.tar.gz
142GiB 0:05:30 [ 500MiB/s] [==============================>] 100%  

References