pv命令

原来pv命令这么好玩(Simulate typing)

[bash toolbar=”false” light=”true”]
$ echo “You can simulate on-screen typing just like in the movies” | pv -qL 10
[/bash]

commandfu上还有一些pv相关的,大都与进度条相关。

[bash toolbar=”false” light=”true”]
$ pv file1 > file2 #copy文件,并显示进度条
[/bash]

pv的man文档里也有几个有用的例子可以参考。

A simple example to watch how quickly a file is transferred using nc(1):

[bash toolbar=”false” light=”true”]
pv file | nc -w 1 somewhere.com 3000
[/bash]

A similar example, transferring a file from another process and passing the expected size to pv:

[bash toolbar=”false” light=”true”]
cat file | pv -s 12345 | nc -w 1 somewhere.com 3000
[/bash]

A more complicated example using numeric output to feed into the dialog(1) program for a full-screen progress display:

[bash toolbar=”false” light=”true”]
(tar cf – . \
| pv -n -s $(du -sb . | awk ‘{print $1}’) \
| gzip -9 > out.tgz) 2>&1 \
| dialog –gauge ‘Progress’ 7 70
[/bash]

发表评论

电子邮件地址不会被公开。 必填项已用*标注