linux 命令pv_Linux pv命令教程,其中包含监视复制/备份/压缩进度的示例

Linux pv命令是一个辅助工具,用于在管道或操作中显示进度条。它可以显示时间流逝、完成百分比、剩余百分比、传输的总数据、预计剩余时间和速率等信息。本文介绍了pv命令的简单用法、仅显示显示栏、仅显示经过时间、仅显示预计到达时间、显示速率、显示传输数据大小以及刷新间隔等不同选项的示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

linux 命令pv

linux 命令pv

When copying, moving files or making backups if the operation requires long time we want to know the progress of the operation. By default most of the Linux tools do not provide this ability by native . pv command is an auxiliary tool used to implement the progress bar about the pipe or operation. Pv command can provide following information

当复制,移动文件或进行备份(如果操作需要很长时间)时,我们想知道操作的进度。 默认情况下,大多数Linux工具都不通过本机提供此功能。 pv命令是辅助工具,用于实现有关管道或操作的进度条。 光伏指令可以提供以下信息

  • Time elapsed

    时间流逝
  • Completion percentage

    完成百分比
  • Remaining Percentage

    剩余百分比
  • Total data transferred

    传输的总数据
  • Estimated Time Remaining

    预计剩余时间

简单用法(Simple Usage)

As stated previously pv command will monitor the pipeline or copy operation. We will copy test.deb as  test2.deb and monitor copy process by piping it.

如前所述,pv命令将监视管道或复制操作。 我们将test.deb复制为test2.deb并通过管道监控复制过程。

$ cp test.deb test2.deb | pv
Simple Usage
Simple Usage
简单用法

仅显示显示栏(Show Only Display Bar)

We can only show the bar. This will hide all other information.

我们只能显示酒吧。 这将隐藏所有其他信息。

$ cp test.deb test2.deb | pv -p
Show Only Display Bar
Show Only Display Bar
仅显示显示栏

仅显示经过的时间(Show Only Elapsed Time)

We can only show the elapsed timer. This will hide all other information.

我们只能显示经过的计时器。 这将隐藏所有其他信息。

$ cp test.deb test2.deb | pv --timer
Show Elapsed Time
Show Elapsed Time
显示经过时间

仅显示预计到达时间(Show Only ETA)

Tracking estimated time is important.We can show ETA with the --eta option like below.

跟踪估计的时间很重要,我们可以使用--eta选项显示ETA,如下所示。

$ cp test.deb test2.deb | pv --eta

显示率 (Show Rate)

We can only show the rate. This will hide all other information.

我们只能显示汇率。 这将隐藏所有其他信息。

$ cp test.deb test2.deb | pv --rate
Show Rate
Show Rate
显示率

仅显示传输的数据大小(Show Only Transferred Data Size)

We can only show the transferred data size. This will hide all other information.

我们只能显示传输的数据大小。 这将隐藏所有其他信息。

$ cp test.deb test2.deb | pv --bytes

刷新指定间隔 (Refresh Specified Interval)

While showing statistics there will be some information refresh. This refresh interval can be specified with -i . In the example we set refresh interval time as 2 seconds.

显示统计信息时,将刷新一些信息。 可以使用-i指定此刷新间隔。 在示例中,我们将刷新间隔时间设置为2秒。

$ cp test.deb test2.deb | pv -i 2

(Version)

Version of the pv command can be shown with --version option like below.

可以使用--version选项显示pv命令的版本,如下所示。

$ pv --version
Version
Version
LEARN MORE  Windows Robocopy Command Tutorial with Examples To Copy Files In Safe Way
了解更多Windows Robocopy命令教程,并提供以安全方式复制文件的示例

翻译自: https://www.poftut.com/linux-pv-command-tutorial-examples-monitor-progress-copybackupcompress/

linux 命令pv

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值