Lesson 40: pv Command
In this lesson, you'll learn how to use the pv command to monitor the progress of data being transferred through a pipeline in Linux.
thatpv is a terminal-based tool that allows you to monitor the progress of data that is being sent through a pipe.
When using the pv command, it gives you a visual display of the following information:
- The time that has elapsed.
- The percentage completed, including a progress bar.
- Current throughput rate.
- The total data transferred.
- The ETA (Estimated Time of Arrival).
Install pv on Linux
The pv command is not installed by default on most Linux distributions. You can install it by following the steps below.
Install pv on RHEL-based Linux:
First, you need to turn on the EPEL repository and then run the following yum or dnf command to install it.
# yum install pv
Or:
# dnf install pv
Install pv on Debian-based Linux:
$ sudo apt-get install pv
Install pv on Other Linux Distributions:
$ sudo emerge -a pv # Gentoo Linux
$ sudo apk add pv # Alpine Linux
$ sudo pacman -S pv # Arch Linux
$ sudo zypper install pv # OpenSUSE
pv Command Syntax
pv is mostly used with other programs that lack the ability to monitor the progress of an ongoing operation.
You can use it by placing it in a pipeline between two processes, with the appropriate options available.
The standard input of pv will be passed through to its standard output, and progress (output) will be printed on standard error.
It has a similar behavior to the cat command in Linux.
The syntax of the pv command is as follows:
$ pv FILE
$ pv OPTIONS FILE
$ pv FILE > filename.out
$ pv OPTIONS | command > filename.out
$ command1 | pv | command2