pv Pipe progress viewer

Version 1.11.0 · source

Start here

pv <file> > <copy>
Copy with progress
<cmd> | pv | <cmd>
Watch a pipe
pv -s <size> ...
Give total for ETA
pv -L 1m
Cap speed at 1 MiB/s
pv -N <name> -c
Label a bar
pv -d <pid>
Watch a running process
pv -q -L <rate>
Throttle silently
pv -F '%t %b'
Custom display

Concepts

  1. producer cat, tar, dd
  2. pv counts and throttles
  3. consumer gzip, ssh, file

Basics

pv <file> > <copy>
Copy a file with progress bar
pv <file> | <command>
Feed a file to a command with progress
<command> | pv > <file>
Watch output of a command
pv < <in> | <command>
Same, reading from stdin
pv -o <file>
Write to a file instead of stdout
Truncates an existing file.
pv -V
Show version

Display

pv -p
Progress bar only
pv -t
Elapsed time only
Handy as a stopwatch: sleep 10m | pv -t
pv -e
Show ETA (needs size)
pv -r
Show current rate
pv -a
Show average rate
pv -b
Show bytes transferred
pv -ptebar
Everything at once
pv -I
Show estimated finish time
pv -8
Show bits instead of bytes
pv -k
Use powers of 1000 (SI)
Place it before the options it should affect.
pv -v
Print rate statistics at the end
pv -T
Show transfer buffer fill
pv -u <style>
Bar style: plain, block, granular, shaded
pv -w <cols>
Force display width
pv -i <sec>
Update interval (default 1)
pv -m <sec>
Window for average rate and ETA

Size and counting

pv -s <size>
Expected total (K, M, G, T suffix)
pv -s @<path>
Take size from a file or directory
pv -s $(du -sb <dir> | cut -f1)
Size of a directory in bytes
pv -s $(stat -c %s <file>)
Size of a file for piped input
pv -l
Count lines, not bytes
With -l, -s is a line count.
pv -0
Count NUL-terminated records
pv -S -s <size>
Stop after size bytes
pv -g
Gauge for unknown size
pv -W
Wait for first byte before timing
Useful after an ssh password prompt.
pv -D <sec>
Show nothing for the first seconds

Rate and transfer

pv -L <rate>
Limit throughput (bytes/s, suffixes)
pv -q -L <rate>
Throttle with no display
pv -q
No output
pv -B <bytes>
Transfer buffer size
pv -C
Do not use splice
Needed for -A, %L and similar buffer-based displays.
pv -E
Skip read errors, pad with NULs
pv -EE
Same, report each file's error once
pv -Z <bytes>
Skip fixed blocks after an error
pv -O
Write sparse output
pv -X
Read and discard input
pv -Y
Sync to disk after each write
pv -U <file>
Store input first, then forward

Names and multiple bars

pv -N <name>
Prefix the bar with a name
pv -c
Cursor positioning for several bars
pv -cN in | gzip -d | pv -cN out
Two labelled bars in one pipe
pv -f
Force display when stderr is no tty
pv -x window
Also show progress in window title
pv -x process
Also show progress in process title

Format and scripting

pv -F '<format>'
Custom display format
pv -F '%b %t %r %p %e'
Default format spelled out
pv -n
Integer percentages on stderr
For dialog --gauge and similar front ends.
pv -nbt
Numeric with bytes and time
pv -F '%{progress-amount-only}'
Percent only
Format sequences
Sequence Shows
%p Progress bar
%t Elapsed time
%e ETA
%I Finish time
%r Current rate
%a Average rate
%b Bytes
%T Buffer fill
%N Name
%% Literal percent

Other processes

pv -d <pid>
Watch all files a process has open
pv -d <pid>:<fd>
Watch one file descriptor
pv -d =<name>
Find the process by name
pv -d @<listfile>
Read targets from a file
pv -Q <pid>
Show progress of another pv
pv -R <pid> -L <rate>
Change a running pv's options
pv -M both -- <command>
Monitor a command's input and output
pv -P <pidfile>
Write pid to a file

Recipes

Archive a directory with progress
tar cf - <dir>/ | pv -s $(du -sb <dir>/ | cut -f1) | gzip -9 > <dir>.tar.gz
Extract with progress
pv <archive>.tar.gz | tar xzf -
Image a disk, skip bad sectors
pv -EE /dev/<disk> > <disk>.imgpv <disk>.img > /dev/<disk>
Throttled copy over ssh
pv -L 2m <file> | ssh <host> 'cat > <file>'# watch an already running gzippv -d $(pidof gzip)