Linux Pipe Viewer

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

1
2
$ sudo apt update
$ sudo apt install pv pigz

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

Usage

Copy File

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

Tape Archive Decompression

1
2
$ 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

1
2
$ 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

Author

Lei Mao

Posted on

06-25-2021

Updated on

06-25-2021

Licensed under


Comments