Linuxユーティリティコマンド-pv

2796 ワード

pvはPipe Viewerの略称で、Andrew Woodが開発したもので、データ処理の進捗状況をパイプラインで表示する情報を意味し、これらの情報には、すでに消費された時間、完了した割合、現在の速度、すべての転送されたデータ、および推定残りの時間が含まれる.

Install

# Debian  ,  Ubuntu
apt-get install pv

# RedHat  ,  CentOS:
yum install pv

Usage

pv [OPTION] [FILE]...

Options

-p, --progress           show progress bar
-t, --timer              show elapsed time
-e, --eta                show estimated time of arrival (completion)
-I, --fineta             show absolute estimated time of arrival
                         (completion)
-r, --rate               show data transfer rate counter
-a, --average-rate       show data transfer average rate counter
-b, --bytes              show number of bytes transferred
-T, --buffer-percent     show percentage of transfer buffer in use
-A, --last-written NUM   show NUM bytes last written
-F, --format FORMAT      set output format to FORMAT
-n, --numeric                 
-q, --quiet              do not output any transfer information at all

-W, --wait               display nothing until first byte transferred
-D, --delay-start SEC    display nothing until SEC seconds have passed
-s, --size SIZE          set estimated data size to SIZE bytes
-l, --line-mode          count lines instead of bytes
-0, --null               lines are null-terminated
-i, --interval SEC       update every SEC seconds
-w, --width WIDTH        assume terminal is WIDTH characters wide
-H, --height HEIGHT      assume terminal is HEIGHT rows high
-N, --name NAME          prefix visual information with NAME
-f, --force              output even if standard error is not a terminal
-c, --cursor             use cursor positioning escape sequences

-L, --rate-limit RATE    limit transfer to RATE bytes per second
-B, --buffer-size BYTES  use a buffer size of BYTES
-C, --no-splice          never use splice(), always use read/write
-E, --skip-errors        skip read errors in input
-S, --stop-at-size       stop after --size bytes have been transferred
-R, --remote PID         update settings of process PID

-P, --pidfile FILE       save process ID in FILE

-d, --watchfd PID[:FD]   watch file FD opened by process PID

-h, --help                   
-V, --version                  

Demo


ファイルのコピー
pv ~/Downloads/CentOS-7-x86_64-Minimal-1511.iso > ~/Desktop/CentOS-7-x86_64-Minimal-1511.iso

ファイルのコピー(速度制限2 MB/s)*
pv -L 2m ~/Downloads/CentOS-7-x86_64-Minimal-1511.iso > ~/Desktop/CentOS-7-x86_64-Minimal-1511.iso

フォルダのコピー*
SRC="/data"; TRG="/data1"; tar cf - "$SRC" | pv -s $(du -sb "$SRC" | cut -f1) | tar xf - -C "$TRG"