UNPKG

3.91 kBMarkdownView Raw
1pv
2===
3
4显示当前在命令行执行的命令的进度信息,管道查看器
5
6## 补充说明
7
8**pv命令** Pipe Viewer 的简称,由Andrew Wood 开发。意思是通过管道显示数据处理进度的信息。这些信息包括已经耗费的时间,完成的百分比(通过进度条显示),当前的速度,全部传输的数据,以及估计剩余的时间。
9
10## 下载安装
11
12```shell
13# Debian 系的操作系统,如 Ubuntu
14sudo apt-get install pv
15
16# RedHat系的则这样:
17yum install pv
18```
19
20### 语法
21
22```shell
23pv(选项)(参数)
24pv [OPTION] [FILE]...
25```
26
27### 选项
28
29```shell
30-p, --progress show progress bar
31-t, --timer show elapsed time
32-e, --eta show estimated time of arrival (completion)
33-I, --fineta show absolute estimated time of arrival
34 (completion)
35-r, --rate show data transfer rate counter
36-a, --average-rate show data transfer average rate counter
37-b, --bytes show number of bytes transferred
38-T, --buffer-percent show percentage of transfer buffer in use
39-A, --last-written NUM show NUM bytes last written
40-F, --format FORMAT set output format to FORMAT
41-n, --numeric 输出百分比
42-q, --quiet do not output any transfer information at all
43
44-W, --wait display nothing until first byte transferred
45-D, --delay-start SEC display nothing until SEC seconds have passed
46-s, --size SIZE set estimated data size to SIZE bytes
47-l, --line-mode count lines instead of bytes
48-0, --null lines are null-terminated
49-i, --interval SEC update every SEC seconds
50-w, --width WIDTH assume terminal is WIDTH characters wide
51-H, --height HEIGHT assume terminal is HEIGHT rows high
52-N, --name NAME prefix visual information with NAME
53-f, --force output even if standard error is not a terminal
54-c, --cursor use cursor positioning escape sequences
55
56-L, --rate-limit RATE limit transfer to RATE bytes per second
57-B, --buffer-size BYTES use a buffer size of BYTES
58-C, --no-splice never use splice(), always use read/write
59-E, --skip-errors skip read errors in input
60-S, --stop-at-size stop after --size bytes have been transferred
61-R, --remote PID update settings of process PID
62
63-P, --pidfile FILE save process ID in FILE
64
65-d, --watchfd PID[:FD] watch file FD opened by process PID
66
67-h, --help 显示帮助
68-V, --version 显示版本信息
69```
70
71
72### 实例
73
74我们(在 linux 上使用命令行的用户)的大多数使用场景都会用到的命令是从一个 USB 驱动器拷贝电影文件到你的电脑。如果你使用 cp 来完成上面的任务,你会什么情况都不清楚,直到整个复制过程结束或者出错。
75
76```shell
77# 复制文件会有进度
78linux [master●] % pv ~/Downloads/CentOS-7-x86_64-Minimal-1511.iso > ~/Desktop/CentOS-7-x86_64-Minimal-1511.iso
79# 下面输入信息
80552MiB 0:00:02 [ 212MiB/s] [==================> ] 91% ETA 0:00:00
81
82# -L 可以让你修改 pv 命令的传输速率。
83# 使用 -L 选项来限制传输速率为2MB/s。
84pv -L 2m /media/himanshu/1AC2-A8E3/fNf.mkv > ./Desktop/fnf.mkv
85```
86
87
88```shell
89# 字符一个个匀速在命令行中显示出来
90echo "Tecmint[dot]com is a community of Linux Nerds and Geeks" | pv -qL 10
91
92# 压缩文件展示进度信息
93pv /media/himanshu/1AC2-A8E3/fnf.mkv | gzip > ./Desktop/fnf.log.gz
94
95
96# 用 dd 命令将 iso 写入磁盘,pv来实现进度条的显示
97sudo pv -cN source < /Users/kacperwang/Downloads/CentOS-7-x86_64-Everything-1511.iso | sudo dd of=/dev/disk2 bs=4m
98## 显示下面进度
99source: 5.2GiB 5:11:41 [ 503KiB/s] [=====================> ] 71% ETA 2:01:56
100```
101
102<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
\No newline at end of file