pv Linux command
The Linux pv command, short for “pipe viewer,” is a powerful utility that allows users to monitor the progress of data being transferred through a pipeline. With pv, you can track data flow, speed up transfers by applying rate limiting, and seamlessly manage multiple streams of data. This command is particularly useful for tasks such as copying large files, creating backups, and transferring data between different systems. By providing real-time information on throughput, duration, and progress, pv helps users optimize their data transfer processes and ensure efficient execution of tasks.
pv Syntax:
Options:
Option | Description |
---|---|
-q, —quiet | Suppresses output from pv |
-b, —bytes | Show the progress in bytes |
-n, —numeric | Print the output without visual bars |
-L, —line-mode | Output one line with progress |
-s, —size | Sets the size of the input in bytes |
-w, —wait | Waits for both pipes to open before starting |
-e, —eta | Shows the estimated time of completion |
-r, —rate-limit | Limit the transfer rate in bytes per second |
-B, —buffer-size | Sets the buffer size for the transfer |
-c, —cursor | Hide the cursor |
Parameters:
Parameter | Description |
---|---|
file | The file to be monitored by pv |
pv bash Examples:
Copy a File with Progress Bar
This command copies the content of “file.txt” to “newfile.txt” while displaying the progress bar.
Monitor Data Transfer Between Processes
This command archives the “/folder” contents, sends the data to pv to monitor the transfer, and then extracts the data to “/destination”.
Limit Data Transfer Speed
The command limits the transfer rate to 1MB per second while writing the “file.iso” content to a block device (/dev/sdX).
Display Transfer Rate Between Files
It copies the content of “file1.txt” to “file2.txt” and displays the transfer rate between the two files.
Show Progress while Compressing Files
This command creates a compressed archive of the “/folder” content, using pv to display the progress bar, and then saves it to “archive.tar.gz”.
Check Disk Write Speed
It measures the write speed of a block device “/dev/sdX” by writing 100MB of zeros using dd and displaying the progress with pv.
How do I install pv in Linux?
To install the pv command in Linux, you can use the package manager of your distribution. For example, on Debian-based systems, you can run:
How can I monitor the progress of a data transfer using pv?
To monitor the progress of a data transfer using pv, you can use it along with other commands like dd
by piping the data through pv. For example:
How can I limit the transfer rate using pv in Linux?
To limit the transfer rate using pv in Linux, you can specify the desired rate using the -L
flag followed by the rate. For example:
How can I display the progress bar with elapsed time using pv?
To display the progress bar along with the elapsed time using pv, you can add the -t
or --timer
option to the command. For example:
How can I show the current data transfer rate using pv in Linux?
To show the current data transfer rate using pv in Linux, you can add the -r
option to display the rate. For example:
How can I display the passed and remaining bytes using pv?
To display both the passed and remaining bytes during a data transfer using pv, you can use the -e
option. For example:
How can I ignore the SIGINT signal using pv in Linux?
To ignore the SIGINT signal (Ctrl+C) while using pv in Linux, you can include the -i 0
option in your command. For example:
Applications of the pv command
- Monitor the progress of data through a pipeline
- Show the throughput of data transfer
- Create progress bars for data transfer
- Limit the transfer rate of data
- Display statistics about the data transfer process