diff --git a/docs/pv.1 b/docs/pv.1 index 886d104..da59732 100644 --- a/docs/pv.1 +++ b/docs/pv.1 @@ -1,11 +1,12 @@ -.TH PV 1 "October 2024" Linux "User Manuals" +.TH PV 1 2024-12-01 pv-1.9.0 "User Commands" +.\" .SH NAME pv \- monitor the progress of data through a pipe - +.\" .SH SYNOPSIS .B pv [\fIOPTION\fR]... [\fIFILE\fR]... - +.PP .SY pv .OP \-pteIrab8kTv .OP \-A NUM @@ -28,7 +29,7 @@ pv \- monitor the progress of data through a pipe .OP \-P FILE .RI [ FILE \&.\|.\|.\&] - +.PP .SY pv .B \-n .OP \-trbv @@ -45,7 +46,7 @@ pv \- monitor the progress of data through a pipe .OP \-P FILE .RI [ FILE \&.\|.\|.\&] - +.PP .SY pv .B \-q .OP \-v @@ -59,7 +60,7 @@ pv \- monitor the progress of data through a pipe .OP \-P FILE .RI [ FILE \&.\|.\|.\&] - +.PP .SY pv .B \-R .I PID @@ -73,7 +74,7 @@ pv \- monitor the progress of data through a pipe .OP \-N NAME .OP \-L RATE .OP \-B BYTES - +.PP .SY pv .B \-d .I PID:FD @@ -82,7 +83,7 @@ pv \- monitor the progress of data through a pipe .OP \-i SEC .OP \-w WIDTH .OP \-H HEIGHT - +.PP .SY pv .B \-d .I PID @@ -91,218 +92,92 @@ pv \- monitor the progress of data through a pipe .OP \-i SEC .OP \-w WIDTH .OP \-H HEIGHT - +.PP .SY pv .B \-h - +.PP .SY pv .B \-V .YS - +.\" .SH DESCRIPTION -.B pv -shows the progress of data through a pipeline by giving information such as +Show the progress of data through a pipeline by giving information such as time elapsed, percentage completed (with progress bar), current throughput rate, total data transferred, and ETA. - -To use it, insert it in a pipeline between two processes, with the -appropriate options. Its standard input will be passed through to its -standard output and progress will be shown on standard error. - -.B pv -will copy each supplied -.I FILE -in turn to standard output -.BR "" "(" \- -means standard input), or if no -.IR FILE s -are specified just standard input is copied. This is the same behaviour -as -.BR cat (1). - -A simple example to watch how quickly a file is transferred using -.BR nc (1): - -.in +4 -.EX -pv file | nc \-w 1 somewhere.com 3000 -.EE -.in - -A similar example, transferring a file from another process and passing the -expected size to -.BR pv : - -.in +4 -.EX -cat file | pv \-s 12345 | nc \-w 1 somewhere.com 3000 -.EE -.in - -A more complicated example using numeric output to feed into the -.BR dialog (1) -program for a full-screen progress display: - -.in +4 -.EX -(tar cf \- . \e -| pv \-n \-s $(du \-sb . | awk '{print $1}') \e -| gzip \-9 > out.tgz) 2>&1 \e -| dialog \-\-gauge 'Progress' 7 70 -.EE -.in - -Taking an image of a disk, skipping errors: - -.in +4 -.EX -pv \-EE /dev/your/disk/device > disk-image.img -.EE -.in - -Writing an image back to a disk: - -.in +4 -.EX -pv disk-image.img > /dev/your/disk/device -.EE -.in - -Zeroing a disk: - -.in +4 -.EX -pv < /dev/zero > /dev/your/disk/device -.EE -.in - -Note that if the input size cannot be calculated, and the output is a block -device, then the size of the block device will be used and -.B pv -will automatically stop at that size as if -.B \-S -had been given. - -(Linux only): Watching file descriptor 3 opened by another process 1234: - -.in +4 -.EX -pv \-d 1234:3 -.EE -.in - -(Linux only): Watching all file descriptors used by process 1234: - -.in +4 -.EX -pv \-d 1234 -.EE -.in - - +.PP +Each \fIFILE\fR is copied to standard output. +With no \fIFILE\fR, or when \fIFILE\fR is \*(lq-\*(rq, standard input is +read. +This is the same behaviour as \fBcat\fR(1). +.\" .SH OPTIONS -.B pv -takes many options, which are divided into display switches, output -modifiers, and general options. - - -.SH DISPLAY SWITCHES -If no display switches are specified, -.B pv -behaves as if -.BR \-p ", " \-t ", " \-e ", " \-r ", and " \-b -had been given. Otherwise, only those display types that are explicitly -switched on will be shown. +.\" +.SS "Display switches" +If no display switches are specified, \fBpv\fR behaves as if +\*(lq\fB\-\-progress\fR\*(rq, \*(lq\fB\-\-timer\fR\*(rq, +\*(lq\fB\-\-eta\fR\*(rq, \*(lq\fB\-\-rate\fR\*(rq, and +\*(lq\fB\-\-bytes\fR\*(rq had been given. +Otherwise, only those display types that are explicitly switched on will be +shown. .TP .B \-p, \-\-progress -Turn the progress bar on. If any inputs are not files, or are -unreadable, and no size was explicitly given (with the -.B \-s -modifier), the progress bar cannot indicate how close to completion the -transfer is, so it will just move left and right to indicate that data is -moving - or, with -.BR \-\-gauge , -the bar will indicate the current rate as a percentage of the maximum rate -seen so far. +Turn the progress bar on. +If any inputs are not files, or are unreadable, and no size was explicitly +given with \*(lq\fB\-\-size\fR\*(rq, the progress bar cannot indicate how +close to completion the transfer is, so it will just move left and right to +indicate that data is moving - or, with \*(lq\fB\-\-gauge\fR\*(rq, the bar +will indicate the current rate as a percentage of the maximum rate seen so +far. .TP .B \-t, \-\-timer -Turn the timer on. This will display the total elapsed time that -.B pv -has been running for. +Turn the timer on. +This will display the total elapsed time that \fBpv\fR has been running for. .TP .B \-e, \-\-eta -Turn the ETA timer on. This will attempt to guess, based on current -transfer rates and the total data size, how long it will be before -completion. The countdown is prefixed with "ETA". This option will have no -effect if the total data size cannot be determined. +Turn the ETA countdown on. +This will estimate, based on current transfer rates and the total data size, +how long it will be before completion. +The countdown is prefixed with \*(lqETA\*(rq. +This option will have no effect if the total data size cannot be determined. .TP .B \-I, \-\-fineta -Turn the ETA timer on, but display the estimated local time at which the -transfer will finish, instead of the amount of time remaining. When the -estimated time is more than 6 hours in the future, the date is shown as -well. The time is prefixed with "FIN" for finish time. As with -.BR \-\-eta , -this option will have no effect if the total data size cannot be determined. +Turn the ETA countdown on, but display the estimated local time at which the +transfer will finish, instead of the amount of time remaining. +When the estimated time is more than 6 hours in the future, the date is +shown as well. +The time is prefixed with \*(lqFIN\*(rq for finish time. +As with \*(lq\fB\-\-eta\fR\*(rq, this option will have no effect if the +total data size cannot be determined. .TP .B \-r, \-\-rate -Turn the rate counter on. This will display the current rate of data -transfer. The rate is shown in square brackets []. +Turn the rate counter on. +This will display the current rate of data transfer. +The rate is shown in square brackets \*(lq[]\*(rq. .TP .B \-a, \-\-average\-rate -Turn the average rate counter on. This will display the current average -rate of data transfer (default: last 30s, see -.BR \-m ). -The average rate is shown in brackets (). +Turn the average rate counter on. +This will display the current average rate of data transfer, over the last +30 seconds by default (see \*(lq\fB\-\-average-rate-window\fR\*(rq). +The average rate is shown in brackets \*(lq()\*(rq. .TP .B \-b, \-\-bytes -Turn the total byte counter on. This will display the total amount of -data transferred so far. -.TP -.B \-8, \-\-bits -Display the total bits instead of the total bytes. The output suffix will -be "b" instead of "B". -.TP -.B \-k, \-\-si -Display and interpret suffixes as multiples of 1000 rather than the default -of 1024. Note that this only takes effect on options after this one, so for -consistency, specify this option first. +Turn the total byte counter on. +This will display the total amount of data transferred so far. .TP .B \-T, \-\-buffer\-percent -Turn on the transfer buffer percentage display. This will show the -percentage of the transfer buffer in use - but see the caveat under -.B %T -in the -.B FORMATTING -section below. Implies -.BR \-C . -The transfer buffer percentage is shown in curly brackets {}. +Turn on the transfer buffer percentage display. +This will show the percentage of the transfer buffer in use. +Implies \*(lq\fB\-\-no\-splice\fR\*(rq. +The transfer buffer percentage is shown in curly brackets \*(lq{}\*(rq. .TP .BI \-A\ NUM \fR,\ \fB\-\-last\-written\ NUM -Show the last -.I NUM -bytes written - but see the caveat under -.B %nA -in the -.B FORMATTING -section below. Implies -.BR \-C . +Show the last \fINUM\fR bytes written. +Implies \*(lq\fB\-\-no\-splice\fR\*(rq. .TP .BI \-F\ FORMAT \fR,\ \fB\-\-format\ FORMAT -Ignore the options -.BR \-p , -.BR \-t , -.BR \-e , -.BR \-r , -.BR \-a , -.BR \-b , -.BR \-T , -and -.BR \-A , -and instead use the format string -.I FORMAT -to determine the output format. See the -.B FORMATTING -section below. +Ignore all of the above options and instead use the format string +\fIFORMAT\fR to determine the output format. +See the \fBFORMATTING\fR section below. .TP .BI \-x\ SPEC \fR,\ \fB\-\-extra\-display\ SPEC As well as displaying progress to the terminal, also write it to \fISPEC\fR. @@ -319,93 +194,73 @@ process title. .TP .B \-v, \-\-stats At the end of the transfer, write an additional line showing the transfer -rate minimum, maximum, mean, and standard deviation. The values are always -in bytes per second (or bits, with -.BR \-8 ). +rate minimum, maximum, mean, and standard deviation. +The values are always in bytes per second (or bits, with +\*(lq\fB\-\-bits\fR\*(rq). .TP .B \-n, \-\-numeric -Numeric output. Instead of giving a visual indication of progress, -.B pv -will give an integer percentage, one per line, on standard error, suitable -for piping (via convoluted redirection) into -.BR dialog (1). -Note that -.B \-f -is not required if -.B \-n -is being used. +Numeric output. +Instead of giving a visual indication of progress, write an integer +percentage, one per line, on standard error, suitable for passing to a tool +such as \fBdialog\fR(1). +Note that \*(lq\fB\-\-force\fR\*(rq is not required if +\*(lq\fB\-\-numeric\fR\*(rq is being used. .TP .B "" -If -.B \-\-numeric -is in use, then adding -.B \-\-bytes -will cause the number of bytes processed so far to be output instead of a -percentage; if -.B \-\-line\-mode -is also in use as well as -.B \-\-bytes -and -.BR \-\-numeric , -then instead of bytes or a percentage, the number of lines -so far is output. If -.B \-\-rate -is added, then the transfer rate is also output (if -.B \-\-bytes -is in use as well, the rate comes after the byte/line count). -If -.B \-\-timer -is also added, then each output line is -.I prefixed -with the elapsed time so far, as a decimal number of seconds. +Combining \*(lq\fB\-\-numeric\fR\*(rq with \*(lq\fB\-\-bytes\fR\*(rq will +cause the number of bytes processed so far to be output instead of a +percentage. +Adding \*(lq\fB\-\-line\-mode\fR\*(rq as well as \*(lq\fB\-\-bytes\fR\*(rq +writes the number of lines instead of bytes or a percentage. +Adding \*(lq\fB\-\-rate\fR\*(rq adds the transfer rate to each output line +(if \*(lq\fB\-\-bytes\fR\*(rq is also in use, the rate comes after the +byte/line count). +Adding \*(lq\fB\-\-timer\fR\*(rq prefixes each output line with the elapsed +time so far, as a decimal number of seconds. .TP .B \-q, \-\-quiet -No output. Useful if the -.B \-L -option is being used on its own to just limit the transfer rate of a pipe. - - -.SH OUTPUT MODIFIERS +No output. +Useful if the \*(lq\fB\-\-rate\-limit\fR\*(rq option is being used on its +own to limit the transfer rate of a pipe. +.\" +.SS "Output modifiers" +.TP +.B \-8, \-\-bits +Use bits instead of bytes for the byte and rate counters. +The output suffix will be \*(lqb\*(rq instead of \*(lqB\*(rq. +.TP +.B \-k, \-\-si +Display and interpret suffixes as multiples of 1000 rather than the default +of 1024. +Note that this only takes effect on options after this one, so for +consistency, specify this option first. .TP .B \-W, \-\-wait Wait until the first byte has been transferred before showing any progress -information or calculating any ETAs. Useful if the program you are piping to -or from requires extra information before it starts, eg piping data into -.BR gpg (1) -or -.BR mcrypt (1) -which require a passphrase before data can be processed. +information or calculating any ETAs. +Useful if the program you are piping to or from requires extra information +before it starts, such as when piping data into \fBgpg\fR(1) or +\fBmcrypt\fR(1) which require a passphrase before data can be processed. .TP .BI \-D\ SEC \fR,\ \fB\-\-delay\-start\ SEC -Wait until -.I SEC -seconds have passed before showing any progress information, for example in -a script where you only want to show a progress bar if it starts taking a -long time. Note that this can be a decimal such as 0.5. +Wait until \fISEC\fR seconds have passed before showing any progress +information, for example in a script where you only want to show a progress +bar if it starts taking a long time. +The value of \fISEC\fR can be a decimal such as \*(lq0.5\*(rq. .TP .BI \-s\ SIZE \fR,\ \fB\-\-size\ SIZE -Assume the total amount of data to be transferred is -.I SIZE -bytes when calculating percentages and ETAs. The same suffixes of "k", "m" -etc can be used as with -.BR \-L . +Assume the total amount of data to be transferred is \fISIZE\fR bytes when +calculating percentages and ETAs. +A suffix of \*(lqK\*(rq, \*(lqM\*(rq, \*(lqG\*(rq, or \*(lqT\*(rq can be +added to denote kibibytes (*1024), mebibytes, gibibytes, tebibytes. +If \*(lq\fB\-\-si\fR\*(rq appears before this option, suffixes will denote +kilobytes (*1000), megabytes, and so on instead. .TP .B "" -If -.I SIZE -starts with -.BR "@" , -the size of file whose name follows the -.B @ -will be used. +If \fISIZE\fR starts with \*(lq\fB@\fR\*(rq, the size of file whose name +follows the @ will be used. .TP .B "" -Note that -.B \-\-size -has no effect if used with -.BI \-d\ PID -to watch all file descriptors of a process, but will work with -.BR "-d PID:FD" . .TP .B \-g, \-\-gauge If the progress bar is shown but the size is not known, then instead of @@ -413,366 +268,267 @@ moving the bar left and right to show progress, show the current transfer rate as a percentage of the maximum rate seen so far. .TP .B \-l, \-\-line\-mode -Instead of counting bytes, count lines (newline characters). The progress -bar will only move when a new line is found, and the value passed to the -.B \-s -option will be interpreted as a line count. +Instead of counting bytes, count lines (newline characters). +The progress bar will only move when a new line is found, and the value +passed to \*(lq\fB\-\-size\fR\*(rq will be interpreted as a line count. .TP .B "" -If this option is used without -.BR \-s , -the "total size" (in this case, total line count) is calculated by reading -through all input files once before transfer starts. If any inputs are -pipes or non-regular files, or are unreadable, the total size will not be -calculated. +If this option is used without \*(lq\fB\-\-size\fR\*(rq, the "total size" +(in this case, total line count) is calculated by reading through all input +files once before transfer starts. +If any inputs are pipes or non-regular files, or are unreadable, the total +size will not be calculated. .TP .B \-0, \-\-null Count lines as terminated with a null byte instead of with a newline. -This option implies \-\-line\-mode. +This option implies \*(lq\fB\-\-line\-mode\fR\*(rq. .TP .BI \-i\ SEC \fR,\ \fB\-\-interval\ SEC -Wait -.I SEC -seconds between updates. The default is to update every second. -Note that this can be a decimal such as 0.1. +Wait \fISEC\fR seconds between updates. +The default is to update every second. +The value of \fISEC\fR can be a decimal such as \*(lq0.1\*(rq. .TP .BI \-m\ SEC \fR,\ \fB\-\-average-rate-window\ SEC -Compute current average rate over a -.I SEC -seconds window for average rate and ETA calculations (default 30 seconds). +Compute current average rate over a \fISEC\fR seconds window for average +rate and ETA calculations. +The default is 30 seconds. +The value must be an integer. .TP .BI \-w\ WIDTH \fR,\ \fB\-\-width\ WIDTH -Assume the terminal is -.I WIDTH -characters wide, instead of trying to work it out (or assuming 80 if it -cannot be guessed). If this option is used, the output width will not be -adjusted if the width of the terminal changes while the transfer is running. +Assume the terminal is \fIWIDTH\fR columns wide, instead of trying to work +it out (or assuming 80 if it cannot be guessed). +If this option is used, the output width will not be adjusted if the width +of the terminal changes while the transfer is running. .TP .BI \-H\ HEIGHT \fR,\ \fB\-\-height\ HEIGHT -Assume the terminal is -.I HEIGHT -rows high, instead of trying to work it out (or assuming 25 if it -cannot be guessed). If this option is used, the output height will not be -adjusted if the height of the terminal changes while the transfer is -running. +Assume the terminal is \fIHEIGHT\fR rows high, instead of trying to work it +out (or assuming 25 if it cannot be guessed). +If this option is used, the output height will not be adjusted if the height +of the terminal changes while the transfer is running. .TP .BI \-N\ NAME \fR,\ \fB\-\-name\ NAME -Prefix the output information with -.IR NAME . -Useful in conjunction with -.B \-c -if you have a complicated pipeline and you want to be able to tell different -parts of it apart. +Prefix the output information with \fINAME\fR. +Useful in conjunction with \*(lq\fB\-\-cursor\fR\*(rq if you have a +complicated pipeline and you want to be able to tell different parts of it +apart. .TP .B \-f, \-\-force -Force output. Normally, -.B pv -will not output any visual display if standard error is not a terminal. +Force output. +Normally, \fBpv\fR will not output any visual display if standard error is +not a terminal. This option forces it to do so. .TP .B \-c, \-\-cursor Use cursor positioning escape sequences instead of just using carriage -returns. This is useful in conjunction with -.B \-N -(name) if you are using multiple -.B pv -invocations in a single, long, pipeline. - - -.SH DATA TRANSFER MODIFIERS +returns. +This is useful in conjunction with \*(lq\fB\-\-name\fR\*(rq if you are using +multiple \fBpv\fR invocations in a single pipeline. +.\" +.SS "Data transfer modifiers" .TP .BI \-o\ FILE \fR,\ \fB\-\-output\ FILE -Write data to -.I FILE -rather than standard output. If the file already exists, it will be -truncated. +Write data to \fIFILE\fR instead of standard output. +If the file already exists, it will be truncated. .TP .BI \-L\ RATE \fR,\ \fB\-\-rate-limit\ RATE -Limit the transfer to a maximum of -.I RATE -bytes per second. A suffix of "K", "M", "G", or "T" can be added to denote -kibibytes (*1024), mebibytes, and so on. If -.B \-\-si -was also passed, suffixes will denote kilobytes (*1000), megabytes, etc. -Note the caveat about the positioning of -.B \-\-si . +Limit the transfer to a maximum of \fIRATE\fR bytes per second. +The same suffixes as \*(lq\fB\-\-size\fR\*(rq can be used. .TP .BI \-B\ BYTES \fR,\ \fB\-\-buffer-size\ BYTES -Use a transfer buffer size of -.I BYTES -bytes. A suffix of "K", "M", "G", or "T" can be added to denote -kibibytes (*1024), mebibytes, and so on. The default buffer size is the -block size of the input file's filesystem multiplied by 32 (512KiB max), or -400KiB if the block size cannot be determined. This can be useful on -platforms like MacOS which perform better in pipelines with specific buffer -sizes such as 1024. Implies -.BR \-C . +Use a transfer buffer size of \fIBYTES\fR bytes. +The same suffixes as \*(lq\fB\-\-size\fR\*(rq can be used. +The default buffer size is the block size of the input file's filesystem +multiplied by 32 (512KiB max), or 400KiB if the block size cannot be +determined. +This can be useful on platforms like MacOS with pipelines that perform +better with specific buffer sizes such as 1024. +Implies \*(lq\fB\-\-no\-splice\fR\*(rq. .TP .B \-C, \-\-no-splice -Never use -.BR splice (2), -even if it would normally be possible. The -.BR splice (2) -system call is a more efficient way of transferring data from or to a pipe -than regular -.BR read (2) -and -.BR write (2), -but means that the transfer buffer may not be used. This prevents -.B \-A -and -.B \-T -from working, cannot work with -.BR \-X , -and makes -.B \-B -redundant, so using -.BR \-A , -.BR \-T , -.BR \-X , -or -.B \-B -automatically switches on -.BR \-C . -Switching on -.B \-C -results in a small loss of transfer efficiency. -(This option has no effect on systems where -.BR splice (2) -is unavailable). +Never use \fBsplice\fR(2), even if it would normally be possible. +The \fBsplice\fR(2) system call is a more efficient way of transferring data +from or to a pipe than regular \fBread\fR(2) and \fBwrite\fR(2), but means +that the transfer buffer may not be used. +This prevents \*(lq\fB\-\-buffer\-percent\fR\*(rq and +\*(lq\fB\-\-last\-written\fR\*(rq from working, cannot work with +\*(lq\fB\-\-discard\fR\*(rq, and makes \*(lq\fB\-\-buffer\-size\fR\*(rq +redundant, so using any of those options automatically switches on +\*(lq\fB\-\-no\-splice\fR\*(rq. +Switching on this option results in a small loss of transfer efficiency. +It has no effect on systems where \fBsplice\fR(2) is unavailable. .TP .B \-E, \-\-skip-errors -Ignore read errors by attempting to skip past the offending sections. The -corresponding parts of the output will be null bytes. At first only a few -bytes will be skipped, but if there are many errors in a row then the skips -will move up to chunks of 512. This is intended to be similar to -.B dd conv=sync,noerror -but has not been as thoroughly tested. +Ignore read errors by attempting to skip past the offending sections. +The corresponding parts of the output will be null bytes. +At first only a few bytes will be skipped, but if there are many errors in a +row then the skips will move up to chunks of 512. +This is intended to be similar to \*(lq\fIdd\~conv=sync,noerror\fR\*(rq. .TP .B "" -Specify -.B \-E -twice to only report a read error once per file, instead of reporting each -byte range skipped. +Specify \*(lq\fB\-\-skip\-errors\fR\*(rq twice to only report a read error +once per file, instead of reporting each byte range skipped. .TP .BI \-Z\ BYTES \fR,\ \fB\-\-error\-skip\-block\ BYTES -When ignoring read errors with -.BR \-E , -instead of trying to adaptively skip by reading small amounts and skipping +When ignoring read errors with \*(lq\fB\-\-skip\-errors\fR\*(rq, instead of +trying to adaptively skip by reading small amounts and skipping progressively larger sections until a read succeeds, move to the next file -block of -.I BYTES -bytes as soon as an error occurs. There may still be some shorter skips -where the block being skipped coincides with the end of the transfer buffer. +block of \fIBYTES\fR bytes as soon as an error occurs. +There may still be some shorter skips where the block being skipped +coincides with the end of the transfer buffer. +The same suffixes as \*(lq\fB\-\-size\fR\*(rq can be used. .TP .B "" -This option can only be used with -.B \-E +This option can only be used with \*(lq\fB\-\-skip\-errors\fR\*(rq and is intended for use when reading from a block device, such as -.B \-E\ \-Z\ 4K -to skip in 4 kibibyte blocks. This will speed up reads from faulty media, -at the expense of potentially losing more data. +\*(lq\fB\-\-skip\-errors\~\-\-error\-skip\-block\~4K\fR\*(rq +to skip in 4 kibibyte blocks. +This will speed up reads from faulty media, at the expense of potentially +losing more data. .TP .B \-S, \-\-stop-at-size -If a size was specified with -.BR \-s , -stop transferring data once that many bytes have been written, instead of -continuing to the end of input. +If a size was specified with \*(lq\fB\-\-size\fR\*(rq, stop transferring +data once that many bytes have been written, instead of continuing to the +end of input. .TP .B \-Y, \-\-sync -After every write operation, synchronise the buffer caches to disk - see -.BR fdatasync (2). -This has no effect when the output is a pipe. Using -.B \-Y -may improve the accuracy of the progress bar when writing to a slow disk. +After every write operation, synchronise the buffer caches to disk with +\fBfdatasync\fR(2). +This has no effect when the output is a pipe. +Using \*(lq\fB\-\-sync\fR\*(rq may improve the accuracy of the progress bar +when writing to a slow disk. .TP .B \-K, \-\-direct-io -Set the -.B O_DIRECT -flag on all inputs and outputs, if it is available. This will minimise -the effect of caches, at the cost of performance. Due to memory alignment -requirements, it also may cause read or write failures with an error of -"Invalid argument", especially if reading and writing files across a variety -of filesystems in a single -.B pv -call. Use this option with caution. +Set the \fBO_DIRECT\fR flag on all inputs and outputs, if it is available. +This will minimise the effect of caches, at the cost of performance. +Due to memory alignment requirements, it also may cause read or write +failures with an error of \*(lqInvalid argument\*(rq, especially if reading +and writing files across a variety of filesystems in a single \fBpv\fR call. +Use this option with caution. .TP .B \-X, \-\-discard -Instead of transferring input data to standard output, discard it. This is -equivalent to redirecting standard output to -.IR /dev/null , -except that -.BR write (2) -is never called. Implies -.BR \-C . +Instead of transferring input data to standard output, discard it. +This is equivalent to redirecting standard output to \fI/dev/null\fR, +except that \fBwrite\fR(2) is never called. +Implies \*(lq\fB\-\-no\-splice\fR\*(rq. .TP .BI \-U\ FILE \fR,\ \fB\-\-store\-and\-forward\ FILE Instead of passing data through immediately, do it in two stages - first -read all input and write it to -.IR FILE , -and then once the input is exhausted, read all of -.I FILE -and write it to the output. -.I FILE -remains in place afterwards, unless it is -"\fB-\fR", in which case -.B pv -creates a temporary file for this purpose, and automatically removes it -afterwards. +read all input and write it to \fIFILE\fR, and then once the input is +exhausted, read all of \fIFILE\fR and write it to the output. +\fIFILE\fR remains in place afterwards, unless it is +\*(lq\fB-\fR\*(rq, in which case \fBpv\fR creates a temporary file for this +purpose, and automatically removes it afterwards. .TP .B "" This can be useful if you have a pipeline which generates data (your input) quickly but you don't know the size, and you wish to pass it to some slower process, once all of the input has been generated and you know its -size, so you can see its progress. Note that when doing this with -relatively small amounts of data, -.B \-\-no-splice -may be preferable so that pipe buffering doesn't affect the progress -display. +size, so you can see its progress. +Note that when doing this with relatively small amounts of data, +\*(lq\fB\-\-no-splice\fR\*(rq may be preferable so that pipe buffering +doesn't affect the progress display. .TP .BI \-d\ PID\fR[\fB:\fR\fIFD\fR],\ \fB\-\-watchfd\ PID\fR[\fB:\fR\fIFD\fR] -Instead of transferring data, watch file descriptor -.I FD -of process -.IR PID , -and show its progress. The -.B pv -process will exit when -.I FD -either changes to a different file, changes read/write mode, or is closed; -other data transfer modifiers - and remote control - may not be used with -this option. +Instead of transferring data, watch file descriptor \fIFD\fR of process +\fIPID\fR, and show its progress. +The \fBpv\fR process will exit when \fIFD\fR either changes to a different +file, changes read/write mode, or is closed; other data transfer modifiers - +and remote control - may not be used with this option. .TP .B "" -If only a -.I PID -is specified, then that process will be watched, and all regular files and -block devices it opens will be shown with a progress bar. The -.B pv -process will exit when process -.I PID -exits. +If only a \fIPID\fR is specified, then that process will be watched, and all +regular files and block devices it opens will be shown with a progress bar. +The \fBpv\fR process will exit when process \fIPID\fR exits. .TP .BI \-R\ PID \fR,\ \fB\-\-remote\ PID -If -.I PID -is an instance of -.B pv -that is already running, -.BI \-R\ PID -will cause that instance to act as though it had been given -this instance's command line instead. For example, if -.B pv \-L 123K -is running with process ID 9876, then running -.B pv \-R 9876 \-L 321K -will cause it to start using a rate limit of 321KiB instead of 123KiB. +Remotely control another instance of \fBpv\fR with process ID \fIPID\fR, +making it act as though it had been given this instance's command line. +For example, if \*(lq\fBpv\~\-\-rate\-limit\~123K\fR\*(rq is running with +process ID 9876, then running +\*(lq\fBpv\~\-\-remote\~9876\~\-\-rate\-limit\~321K\fR\*(rq will cause +process 9876 to start using a rate limit of 321KiB instead of 123KiB. Note that some options cannot be changed while running, such as -.BR \-c , -.BR \-l , -.BR \-f , -.BR \-D , -.BR \-E , -and -.BR \-S . - -.SH GENERAL OPTIONS +\*(lq\fB\-\-cursor\fR\*(rq, \*(lq\fB\-\-line\-mode\fR\*(rq, +\*(lq\fB\-\-force\fR\*(rq, \*(lq\fB\-\-delay\-start\fR\*(rq, +\*(lq\fB\-\-skip\-errors\fR\*(rq, and \*(lq\fB\-\-stop\-at\-size\fR\*(rq. +.\" +.SS "General options" .TP .BI \-P\ FILE \fR,\ \fB\-\-pidfile\ FILE -Save the process ID of -.B pv -in -.IR FILE . +Save the process ID of \fBpv\fR in \fIFILE\fR. The file will be replaced if it already exists, and will be removed when -.B pv -exits. While -.B pv -is running, it will contain a single number - the process ID of -.B pv -- followed by a newline. +\fBpv\fR exits. +While \fBpv\fR is running, \fIFILE\fR will contain a single number - the +process ID of \fBpv\fR - followed by a newline. .TP .B \-h, \-\-help Print a usage message on standard output and exit successfully. .TP .B \-V, \-\-version Print version information on standard output and exit successfully. - - +.\" .SH FORMATTING -If the -.B \-F -option is given, then the output format is determined by the given format -string. Within that string, the following sequences can be used: +The format string used by \*(lq\fB\-\-format\fR\*(rq and +\*(lq\fB\-\-extra\-display\fR\*(rq can contain the following sequences: .TP .B %p Progress bar. -Expands to fill the remaining space. Should only be specified once. -Equivalent to -.BR \-p . +Expands to fill the remaining space. +Should only be specified once. +Equivalent to \*(lq\fB\-\-progress\fR\*(rq. .TP .B %t -Elapsed time. Equivalent to -.BR \-t . +Elapsed time. +Equivalent to \*(lq\fB\-\-timer\fR\*(rq. .TP .B %e -ETA as time remaining. Equivalent to -.BR \-e . +ETA as time remaining. +Equivalent to \*(lq\fB\-\-eta\fR\*(rq. .TP .B %I -ETA as local time at which the transfer will finish. Equivalent to -.BR \-I . +ETA as local time at which the transfer will finish. +Equivalent to \*(lq\fB\-\-fineta\fR\*(rq. .TP .B %r -Current data transfer rate. Equivalent to -.BR \-r . +Current data transfer rate. +Equivalent to \*(lq\fB\-\-rate\fR\*(rq. .TP .B %a -Average data transfer rate. Equivalent to -.BR \-a . +Average data transfer rate. +Equivalent to \*(lq\fB\-\-average\-rate\fR\*(rq. .TP .B %b -Bytes transferred so far (or lines if -.B \-l -was specified). Equivalent to -.BR \-b . -If -.B \-\-bits -was specified, -.B %b -shows the bits transferred so far, not bytes. +Bytes transferred so far (or lines if \*(lq\fB\-\-line\-mode\fR\*(rq was specified). +Equivalent to \*(lq\fB\-\-bytes\fR\*(rq. +If \*(lq\fB\-\-bits\fR\*(rq was specified, \*(lq\fB%b\fR\*(rq shows the bits +transferred so far, not bytes. .TP .B %T -Percentage of the transfer buffer in use. Equivalent to -.BR \-T . -Shows "{\-\-\-\-}" if the transfer is being done with -.BR splice (2), -since splicing to or from pipes does not use the buffer. +Percentage of the transfer buffer in use. +Equivalent to \*(lq\fB\-\-buffer\-percent\fR\*(rq. +Displays \*(lq{\-\-\-\-}\*(rq if the transfer is being done with +\fBsplice\fR(2), since splicing to or from pipes does not use the buffer. .TP .B %nA -Show the last -.B n -bytes written (e.g. -.B %16A -for the last 16 bytes). -Shows only dots if the transfer is being done with -.BR splice (2), -since splicing to or from pipes does not use the buffer. +Show the last \fIn\fR bytes written (for example, \*(lq\fB%16A\fR\*(rq shows +the last 16 bytes). +Shows only dots if the transfer is being done with \fBsplice\fR(2), since +splicing to or from pipes does not use the buffer. .TP .B %N -Name prefix given by -.BR \-N . -Padded to 9 characters with spaces, and suffixed with :. +Show the name prefix given by \*(lq\fB\-\-name\fR\*(rq. +Padded to 9 characters with spaces, and suffixed with \*(lq:\*(rq. .TP .B %% -A single %. - -.P +A single \*(lq%\*(rq. +.PP +Any other contents are reproduced in the progress display as-is. +.PP The format string equivalent of turning on all display switches is -.BR "\`%N %b %T %t %r %a %p %e %I'" . - - -.SH COMMON SWITCHES +\*(lq\fB%N\~%b\~%T\~%t\~%r\~%a\~%p\~%e\~%I\~%8A\fR\*(rq. +.\" +.SH EXAMPLES Some suggested common switch combinations: - .TP .B pv \-ptebar Show a progress bar, elapsed time, estimated completion time, byte counter, @@ -785,39 +541,103 @@ and average rate, counting lines instead of bytes. .B pv \-btrpg Show the amount transferred, elapsed time, current rate, and a gauge showing the current rate as a percentage of the maximum rate seen - useful in a -pipeline where the total size is unknown. (If the size -.I is -known, these options will show the percentage completion instead of the rate -gauge). +pipeline where the total size is unknown. +(If the size \fIis\fR known, these options will show the percentage +completion instead of the rate gauge). .TP .B pv \-t -Show only the elapsed time - useful as a simple timer, e.g. -.BR "sleep 10m | pv \-t" . +Show only the elapsed time - useful as a simple timer, such as +\*(lq\fBsleep\~10m\~|\~pv\~\-t\fR\*(rq. .TP .B pv \-pterb The default behaviour: progress bar, elapsed time, estimated completion time, current rate, and byte counter. - -.P -On MacOS, it may be useful to specify -.B \-B 1024 +.PP +On MacOS, it may be useful to specify \*(lq\fB\-\-buffer\-size\~1024\fR\*(rq in a pipeline, as this may improve performance. - - +.PP +To watch how quickly a file is transferred using \fBnc\fR(1): +.PP +.in +4 +.EX +pv file | nc \-w 1 somewhere.com 3000 +.EE +.in +.PP +A similar example, transferring a file from another process and passing the +expected size to \fBpv\fR: +.PP +.in +4 +.EX +cat file | pv \-s 12345 | nc \-w 1 somewhere.com 3000 +.EE +.in +.PP +A more complicated example using numeric output to feed into the +\fBdialog\fR(1) program for a full-screen progress display: +.PP +.in +4 +.EX +(tar cf \- . \e +| pv \-n \-s $(du \-sb . | awk '{print $1}') \e +| gzip \-9 > out.tgz) 2>&1 \e +| dialog \-\-gauge 'Progress' 7 70 +.EE +.in +.PP +Taking an image of a disk, skipping errors: +.PP +.in +4 +.EX +pv \-EE /dev/your/disk/device > disk-image.img +.EE +.in +.PP +Writing an image back to a disk: +.PP +.in +4 +.EX +pv disk-image.img > /dev/your/disk/device +.EE +.in +.PP +Zeroing a disk: +.PP +.in +4 +.EX +pv < /dev/zero > /dev/your/disk/device +.EE +.in +.PP +Note that if the input size cannot be calculated, and the output is a block +device, then the size of the block device will be used and \fBpv\fR will +automatically stop at that size as if \*(lq\fB\-\-stop\-at\-size\fR\*(rq had +been given. +.PP +(Linux only): Watching file descriptor 3 opened by another process 1234: +.PP +.in +4 +.EX +pv \-d 1234:3 +.EE +.in +.PP +(Linux only): Watching all file descriptors used by process 1234: +.PP +.in +4 +.EX +pv \-d 1234 +.EE +.in +.\" .SH EXIT STATUS -An exit status of 1 indicates a problem with the -.B \-R -or -.B \-P -options. - +An exit status of 1 indicates a problem with the \*(lq\fB\-\-remote\fR\*(rq +or \*(lq\fB\-\-pidfile\fR\*(rq options. +.PP Any other exit status is a bitmask of the following: - .TP .B 2 -One or more files could not be accessed, -.BR stat (2)ed, -or opened. +One or more files could not be accessed, \fBstat\fR(2)ed, or opened. .TP .B 4 An input file was the same as the output file. @@ -833,145 +653,101 @@ A signal was caught that caused an early exit. .TP .B 64 Memory allocation failed. - -.P +.PP A zero exit status indicates no problems. - - +.\" .SH ENVIRONMENT -The following environment variables may affect -.BR pv : - +The following environment variables may affect \fBpv\fR: .TP .B HOME -The current user's home directory. This may be used by the remote control -mechanism -(the -.B \-\-remote -option) -to exchange messages between -.B pv -instances: if the -.I /run/user/UID/ -directory does not exist (where -.I UID -is the current user ID), then -.I $HOME/.pv/ -will be used instead. +The current user's home directory. +This may be used by \*(lq\fB\-\-remote\fR\*(rq to exchange messages between +\fBpv\fR instances: if the \fI/run/user/UID/\fR directory does not exist +(where \fIUID\fR is the current user ID), then \fI$HOME/.pv/\fR will be used +instead. .TP .BR TMPDIR ", " TMP -The directory to create per-tty lock files for the terminal when using the -.B \-\-cursor -option. If -.B TMPDIR -is set to a non-empty value, it is the directory under which lock files are -created. Otherwise, if -.B TMP -is set, then it is used; and if neither are set, then -.I /tmp -is used. - - -.SH AUTHOR -Written by Andrew Wood, with patches submitted by various other people. -Please see the package's ACKNOWLEDGEMENTS file for a complete list of -contributors. - - -.SH KNOWN PROBLEMS -The following problems are known to exist in -.BR pv : -.IP \(bu 3 -In some versions of -.BR bash (1) -and -.BR zsh (1), -the construct -.B <(pv filename) -will not output any progress to the terminal when run from an interactive -shell, due to the subprocess being run in a separate process group from the -one that owns the terminal. In these cases, use -.BR \-\-force . -.P -.IP \(bu 3 -If -.B pv -is used in a pipeline in -.B zsh -version 5.8, and the last command in the pipeline is based on shell -builtins, -.B zsh -takes control of the terminal away from -.BR pv , -preventing progress from being displayed. For example, this will produce no -progress bar: -.IP +The directory to create per-tty lock files for the terminal when using +\*(lq\fB\-\-cursor\fR\*(rq. +If \fBTMPDIR\fR is set to a non-empty value, it is the directory under which +lock files are created. +Otherwise, \fBTMP\fR is used. +If neither are set, then \fI/tmp\fR is used. +.\" +.SH NOTES +In some versions of \fBbash\fR(1) and \fBzsh\fR(1), the construct +\*(lq\fB<(pv\~filename)\fR\*(rq will not output any progress to the terminal +when run from an interactive shell, due to the subprocess being run in a +separate process group from the one that owns the terminal. +In these cases, use \*(lq\fB\-\-force\fR\*(rq. +.PP +If \fBpv\fR is used in a pipeline in \fBzsh\fR version 5.8, and the last +command in the pipeline is based on shell builtins, \fBzsh\fR takes control +of the terminal away from \fBpv\fR, preventing progress from being +displayed. +For example, this will produce no progress bar: +.PP .in +4n .EX pv InputFile | { while read \-r line; do sleep 0.1; done; } .EE .in -.IP +.PP To work around this, put the last commands of the pipeline in normal brackets to force the use of a subshell: -.IP +.PP .in +4n .EX pv InputFile | ( while read \-r line; do sleep 0.1; done; ) .EE .in -.IP +.PP Refer to .UR https://codeberg.org/a-j-wood/pv/issues/105 issue #105 .UE for full details. -.P -.IP \(bu 3 -The -.B \-c -option does not work properly on Cygwin without -.B cygserver -running, if started near the bottom of the screen (IPC is needed to handle -the terminal scrolling). To fix this, start -.B cygserver -before using -.BR "pv \-c" . -.P -.IP \(bu 3 -The -.B \-R -option requires that either -.B /run/user// -or -.B $HOME/ -can be written to, for inter-process communication. -.P -If you find any other problems, please report them. - - +.PP +The \*(lq\fB\-\-remote\fR\*(rq option requires that either +\fI/run/user//\fR or \fI$HOME/\fR can be written to, for inter-process +communication. +.PP +The \*(lq\fB\-\-size\fR\*(rq option has no effect if used with +\*(lq\fB\-\-watchfd\fR\~\fIPID\fR\*(rq to watch all file descriptors of a +process, but will work with \*(lq\fB\-\-watchfd\fR\~\fIPID\fR:\fIFD\fR\*(rq +to watch a single file descriptor. +.PP +If the input size cannot be calculated, and the output is a block device, +then \fBpv\fR will read the output device's size, use that as if it had been +passed to \*(lq\fB\-\-size\fR\*(rq, and activate +\*(lq\fB\-\-stop\-at\-size\fR\*(rq. +.\" .SH REPORTING BUGS -Please report any bugs to -.BR pv@ivarch.com . - +Please report any bugs to \fBpv@ivarch.com\fR. +.PP Alternatively, use the issue tracker linked from the .UR https://www.ivarch.com/programs/pv.shtml -pv home page +\fBpv\fR home page .UE . - - +.\" .SH "SEE ALSO" .BR cat (1), .BR dialog (1), .BR splice (2), +.BR fdatasync (2), .BR open (2) -(for -.BR O_DIRECT ) - +(for \fBO_DIRECT\fR) +.\" .SH COPYRIGHT Copyright \(co 2002-2008, 2010, 2012-2015, 2017, 2021, 2023-2024 Andrew Wood. - -License GPLv3+: GNU GPL version 3 or later . - +.PP +License GPLv3+: +.UR https://www.gnu.org/licenses/gpl-3.0.html +GNU GPL version 3 or later +.UE . +.PP This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. +.PP +Please see the package's ACKNOWLEDGEMENTS file for a complete list of +contributors. diff --git a/docs/pv.1.md b/docs/pv.1.md index 90708fd..18ba793 100644 --- a/docs/pv.1.md +++ b/docs/pv.1.md @@ -38,20 +38,484 @@ FORMAT \] \[ **-s** SIZE \] \[ **-i** SEC \] \[ **-w** WIDTH \] \[ # DESCRIPTION -**pv** shows the progress of data through a pipeline by giving -information such as time elapsed, percentage completed (with progress -bar), current throughput rate, total data transferred, and ETA. +Show the progress of data through a pipeline by giving information such +as time elapsed, percentage completed (with progress bar), current +throughput rate, total data transferred, and ETA. -To use it, insert it in a pipeline between two processes, with the -appropriate options. Its standard input will be passed through to its -standard output and progress will be shown on standard error. +Each *FILE* is copied to standard output. With no *FILE*, or when *FILE* +is "-", standard input is read. This is the same behaviour as +**cat**(1). -**pv** will copy each supplied *FILE* in turn to standard output (**-** -means standard input), or if no *FILE*s are specified just standard -input is copied. This is the same behaviour as **cat**(1). +# OPTIONS -A simple example to watch how quickly a file is transferred using -**nc**(1): +## Display switches + +If no display switches are specified, **pv** behaves as if +"**\--progress**", "**\--timer**", "**\--eta**", "**\--rate**", and +"**\--bytes**" had been given. Otherwise, only those display types that +are explicitly switched on will be shown. + +**-p, \--progress** + +: Turn the progress bar on. If any inputs are not files, or are + unreadable, and no size was explicitly given with "**\--size**", the + progress bar cannot indicate how close to completion the transfer + is, so it will just move left and right to indicate that data is + moving - or, with "**\--gauge**", the bar will indicate the current + rate as a percentage of the maximum rate seen so far. + +**-t, \--timer** + +: Turn the timer on. This will display the total elapsed time that + **pv** has been running for. + +**-e, \--eta** + +: Turn the ETA countdown on. This will estimate, based on current + transfer rates and the total data size, how long it will be before + completion. The countdown is prefixed with "ETA". This option will + have no effect if the total data size cannot be determined. + +**-I, \--fineta** + +: Turn the ETA countdown on, but display the estimated local time at + which the transfer will finish, instead of the amount of time + remaining. When the estimated time is more than 6 hours in the + future, the date is shown as well. The time is prefixed with "FIN" + for finish time. As with "**\--eta**", this option will have no + effect if the total data size cannot be determined. + +**-r, \--rate** + +: Turn the rate counter on. This will display the current rate of data + transfer. The rate is shown in square brackets "\[\]". + +**-a, \--average-rate** + +: Turn the average rate counter on. This will display the current + average rate of data transfer, over the last 30 seconds by default + (see "**\--average-rate-window**"). The average rate is shown in + brackets "()". + +**-b, \--bytes** + +: Turn the total byte counter on. This will display the total amount + of data transferred so far. + +**-T, \--buffer-percent** + +: Turn on the transfer buffer percentage display. This will show the + percentage of the transfer buffer in use. Implies + "**\--no-splice**". The transfer buffer percentage is shown in curly + brackets "{}". + +**-A NUM, \--last-written NUM** + +: Show the last *NUM* bytes written. Implies "**\--no-splice**". + +**-F FORMAT, \--format FORMAT** + +: Ignore all of the above options and instead use the format string + *FORMAT* to determine the output format. See the **FORMATTING** + section below. + +**-x SPEC, \--extra-display SPEC** + +: As well as displaying progress to the terminal, also write it to + *SPEC*. The *SPEC* must start with a comma-separated list of + destinations, and can optionally be followed by a colon and a format + string. The destinations can be **windowtitle** or **window** for + the xterm window title, and **processtitle**, **proctitle**, + **process**, or **proc** for the process title displayed by + **ps**(1). If a format string is not supplied, the same format is + used as for the terminal. For example, + "**-x \'window,process:%t %b %r\'**" will show the elapsed time, + bytes transferred, and rate, in both the window title and the + process title. + +**-v, \--stats** + +: At the end of the transfer, write an additional line showing the + transfer rate minimum, maximum, mean, and standard deviation. The + values are always in bytes per second (or bits, with "**\--bits**"). + +**-n, \--numeric** + +: Numeric output. Instead of giving a visual indication of progress, + write an integer percentage, one per line, on standard error, + suitable for passing to a tool such as **dialog**(1). Note that + "**\--force**" is not required if "**\--numeric**" is being used. + +: Combining "**\--numeric**" with "**\--bytes**" will cause the number + of bytes processed so far to be output instead of a percentage. + Adding "**\--line-mode**" as well as "**\--bytes**" writes the + number of lines instead of bytes or a percentage. Adding + "**\--rate**" adds the transfer rate to each output line (if + "**\--bytes**" is also in use, the rate comes after the byte/line + count). Adding "**\--timer**" prefixes each output line with the + elapsed time so far, as a decimal number of seconds. + +**-q, \--quiet** + +: No output. Useful if the "**\--rate-limit**" option is being used on + its own to limit the transfer rate of a pipe. + +## Output modifiers + +**-8, \--bits** + +: Use bits instead of bytes for the byte and rate counters. The output + suffix will be "b" instead of "B". + +**-k, \--si** + +: Display and interpret suffixes as multiples of 1000 rather than the + default of 1024. Note that this only takes effect on options after + this one, so for consistency, specify this option first. + +**-W, \--wait** + +: Wait until the first byte has been transferred before showing any + progress information or calculating any ETAs. Useful if the program + you are piping to or from requires extra information before it + starts, such as when piping data into **gpg**(1) or **mcrypt**(1) + which require a passphrase before data can be processed. + +**-D SEC, \--delay-start SEC** + +: Wait until *SEC* seconds have passed before showing any progress + information, for example in a script where you only want to show a + progress bar if it starts taking a long time. The value of *SEC* can + be a decimal such as "0.5". + +**-s SIZE, \--size SIZE** + +: Assume the total amount of data to be transferred is *SIZE* bytes + when calculating percentages and ETAs. A suffix of "K", "M", "G", or + "T" can be added to denote kibibytes (\*1024), mebibytes, gibibytes, + tebibytes. If "**\--si**" appears before this option, suffixes will + denote kilobytes (\*1000), megabytes, and so on instead. + +: If *SIZE* starts with "**@**", the size of file whose name follows + the @ will be used. + +: + +**-g, \--gauge** + +: If the progress bar is shown but the size is not known, then instead + of moving the bar left and right to show progress, show the current + transfer rate as a percentage of the maximum rate seen so far. + +**-l, \--line-mode** + +: Instead of counting bytes, count lines (newline characters). The + progress bar will only move when a new line is found, and the value + passed to "**\--size**" will be interpreted as a line count. + +: If this option is used without "**\--size**", the \"total size\" (in + this case, total line count) is calculated by reading through all + input files once before transfer starts. If any inputs are pipes or + non-regular files, or are unreadable, the total size will not be + calculated. + +**-0, \--null** + +: Count lines as terminated with a null byte instead of with a + newline. This option implies "**\--line-mode**". + +**-i SEC, \--interval SEC** + +: Wait *SEC* seconds between updates. The default is to update every + second. The value of *SEC* can be a decimal such as "0.1". + +**-m SEC, \--average-rate-window SEC** + +: Compute current average rate over a *SEC* seconds window for average + rate and ETA calculations. The default is 30 seconds. The value must + be an integer. + +**-w WIDTH, \--width WIDTH** + +: Assume the terminal is *WIDTH* columns wide, instead of trying to + work it out (or assuming 80 if it cannot be guessed). If this option + is used, the output width will not be adjusted if the width of the + terminal changes while the transfer is running. + +**-H HEIGHT, \--height HEIGHT** + +: Assume the terminal is *HEIGHT* rows high, instead of trying to work + it out (or assuming 25 if it cannot be guessed). If this option is + used, the output height will not be adjusted if the height of the + terminal changes while the transfer is running. + +**-N NAME, \--name NAME** + +: Prefix the output information with *NAME*. Useful in conjunction + with "**\--cursor**" if you have a complicated pipeline and you want + to be able to tell different parts of it apart. + +**-f, \--force** + +: Force output. Normally, **pv** will not output any visual display if + standard error is not a terminal. This option forces it to do so. + +**-c, \--cursor** + +: Use cursor positioning escape sequences instead of just using + carriage returns. This is useful in conjunction with "**\--name**" + if you are using multiple **pv** invocations in a single pipeline. + +## Data transfer modifiers + +**-o FILE, \--output FILE** + +: Write data to *FILE* instead of standard output. If the file already + exists, it will be truncated. + +**-L RATE, \--rate-limit RATE** + +: Limit the transfer to a maximum of *RATE* bytes per second. The same + suffixes as "**\--size**" can be used. + +**-B BYTES, \--buffer-size BYTES** + +: Use a transfer buffer size of *BYTES* bytes. The same suffixes as + "**\--size**" can be used. The default buffer size is the block size + of the input file\'s filesystem multiplied by 32 (512KiB max), or + 400KiB if the block size cannot be determined. This can be useful on + platforms like MacOS with pipelines that perform better with + specific buffer sizes such as 1024. Implies "**\--no-splice**". + +**-C, \--no-splice** + +: Never use **splice**(2), even if it would normally be possible. The + **splice**(2) system call is a more efficient way of transferring + data from or to a pipe than regular **read**(2) and **write**(2), + but means that the transfer buffer may not be used. This prevents + "**\--buffer-percent**" and "**\--last-written**" from working, + cannot work with "**\--discard**", and makes "**\--buffer-size**" + redundant, so using any of those options automatically switches on + "**\--no-splice**". Switching on this option results in a small loss + of transfer efficiency. It has no effect on systems where + **splice**(2) is unavailable. + +**-E, \--skip-errors** + +: Ignore read errors by attempting to skip past the offending + sections. The corresponding parts of the output will be null bytes. + At first only a few bytes will be skipped, but if there are many + errors in a row then the skips will move up to chunks of 512. This + is intended to be similar to "*dd conv=sync,noerror*". + +: Specify "**\--skip-errors**" twice to only report a read error once + per file, instead of reporting each byte range skipped. + +**-Z BYTES, \--error-skip-block BYTES** + +: When ignoring read errors with "**\--skip-errors**", instead of + trying to adaptively skip by reading small amounts and skipping + progressively larger sections until a read succeeds, move to the + next file block of *BYTES* bytes as soon as an error occurs. There + may still be some shorter skips where the block being skipped + coincides with the end of the transfer buffer. The same suffixes as + "**\--size**" can be used. + +: This option can only be used with "**\--skip-errors**" and is + intended for use when reading from a block device, such as + "**\--skip-errors \--error-skip-block 4K**" to skip in 4 kibibyte + blocks. This will speed up reads from faulty media, at the expense + of potentially losing more data. + +**-S, \--stop-at-size** + +: If a size was specified with "**\--size**", stop transferring data + once that many bytes have been written, instead of continuing to the + end of input. + +**-Y, \--sync** + +: After every write operation, synchronise the buffer caches to disk + with **fdatasync**(2). This has no effect when the output is a pipe. + Using "**\--sync**" may improve the accuracy of the progress bar + when writing to a slow disk. + +**-K, \--direct-io** + +: Set the **O_DIRECT** flag on all inputs and outputs, if it is + available. This will minimise the effect of caches, at the cost of + performance. Due to memory alignment requirements, it also may cause + read or write failures with an error of "Invalid argument", + especially if reading and writing files across a variety of + filesystems in a single **pv** call. Use this option with caution. + +**-X, \--discard** + +: Instead of transferring input data to standard output, discard it. + This is equivalent to redirecting standard output to */dev/null*, + except that **write**(2) is never called. Implies + "**\--no-splice**". + +**-U FILE, \--store-and-forward FILE** + +: Instead of passing data through immediately, do it in two stages - + first read all input and write it to *FILE*, and then once the input + is exhausted, read all of *FILE* and write it to the output. *FILE* + remains in place afterwards, unless it is "**-**", in which case + **pv** creates a temporary file for this purpose, and automatically + removes it afterwards. + +: This can be useful if you have a pipeline which generates data (your + input) quickly but you don\'t know the size, and you wish to pass it + to some slower process, once all of the input has been generated and + you know its size, so you can see its progress. Note that when doing + this with relatively small amounts of data, "**\--no-splice**" may + be preferable so that pipe buffering doesn\'t affect the progress + display. + +**-d PID\[:FD\], \--watchfd PID\[:FD\]** + +: Instead of transferring data, watch file descriptor *FD* of process + *PID*, and show its progress. The **pv** process will exit when *FD* + either changes to a different file, changes read/write mode, or is + closed; other data transfer modifiers - and remote control - may not + be used with this option. + +: If only a *PID* is specified, then that process will be watched, and + all regular files and block devices it opens will be shown with a + progress bar. The **pv** process will exit when process *PID* exits. + +**-R PID, \--remote PID** + +: Remotely control another instance of **pv** with process ID *PID*, + making it act as though it had been given this instance\'s command + line. For example, if "**pv \--rate-limit 123K**" is running with + process ID 9876, then running + "**pv \--remote 9876 \--rate-limit 321K**" will cause process 9876 + to start using a rate limit of 321KiB instead of 123KiB. Note that + some options cannot be changed while running, such as + "**\--cursor**", "**\--line-mode**", "**\--force**", + "**\--delay-start**", "**\--skip-errors**", and + "**\--stop-at-size**". + +## General options + +**-P FILE, \--pidfile FILE** + +: Save the process ID of **pv** in *FILE*. The file will be replaced + if it already exists, and will be removed when **pv** exits. While + **pv** is running, *FILE* will contain a single number - the process + ID of **pv** - followed by a newline. + +**-h, \--help** + +: Print a usage message on standard output and exit successfully. + +**-V, \--version** + +: Print version information on standard output and exit successfully. + +# FORMATTING + +The format string used by "**\--format**" and "**\--extra-display**" can +contain the following sequences: + +**%p** + +: Progress bar. Expands to fill the remaining space. Should only be + specified once. Equivalent to "**\--progress**". + +**%t** + +: Elapsed time. Equivalent to "**\--timer**". + +**%e** + +: ETA as time remaining. Equivalent to "**\--eta**". + +**%I** + +: ETA as local time at which the transfer will finish. Equivalent to + "**\--fineta**". + +**%r** + +: Current data transfer rate. Equivalent to "**\--rate**". + +**%a** + +: Average data transfer rate. Equivalent to "**\--average-rate**". + +**%b** + +: Bytes transferred so far (or lines if "**\--line-mode**" was + specified). Equivalent to "**\--bytes**". If "**\--bits**" was + specified, "**%b**" shows the bits transferred so far, not bytes. + +**%T** + +: Percentage of the transfer buffer in use. Equivalent to + "**\--buffer-percent**". Displays "{\-\-\--}" if the transfer is + being done with **splice**(2), since splicing to or from pipes does + not use the buffer. + +**%nA** + +: Show the last *n* bytes written (for example, "**%16A**" shows the + last 16 bytes). Shows only dots if the transfer is being done with + **splice**(2), since splicing to or from pipes does not use the + buffer. + +**%N** + +: Show the name prefix given by "**\--name**". Padded to 9 characters + with spaces, and suffixed with ":". + +**%%** + +: A single "%". + +Any other contents are reproduced in the progress display as-is. + +The format string equivalent of turning on all display switches is +"**%N %b %T %t %r %a %p %e %I %8A**". + +# EXAMPLES + +Some suggested common switch combinations: + +**pv -ptebar** + +: Show a progress bar, elapsed time, estimated completion time, byte + counter, average rate, and current rate. + +**pv -betlap** + +: Show a progress bar, elapsed time, estimated completion time, line + counter, and average rate, counting lines instead of bytes. + +**pv -btrpg** + +: Show the amount transferred, elapsed time, current rate, and a gauge + showing the current rate as a percentage of the maximum rate seen - + useful in a pipeline where the total size is unknown. (If the size + *is* known, these options will show the percentage completion + instead of the rate gauge). + +**pv -t** + +: Show only the elapsed time - useful as a simple timer, such as + "**sleep 10m \| pv -t**". + +**pv -pterb** + +: The default behaviour: progress bar, elapsed time, estimated + completion time, current rate, and byte counter. + +On MacOS, it may be useful to specify "**\--buffer-size 1024**" in a +pipeline, as this may improve performance. + +To watch how quickly a file is transferred using **nc**(1): pv file | nc -w 1 somewhere.com 3000 @@ -82,7 +546,8 @@ Zeroing a disk: Note that if the input size cannot be calculated, and the output is a block device, then the size of the block device will be used and **pv** -will automatically stop at that size as if **-S** had been given. +will automatically stop at that size as if "**\--stop-at-size**" had +been given. (Linux only): Watching file descriptor 3 opened by another process 1234: @@ -92,480 +557,10 @@ will automatically stop at that size as if **-S** had been given. pv -d 1234 -# OPTIONS - -**pv** takes many options, which are divided into display switches, -output modifiers, and general options. - -# DISPLAY SWITCHES - -If no display switches are specified, **pv** behaves as if **-p**, -**-t**, **-e**, **-r**, and **-b** had been given. Otherwise, only those -display types that are explicitly switched on will be shown. - -**-p, \--progress** - -: Turn the progress bar on. If any inputs are not files, or are - unreadable, and no size was explicitly given (with the **-s** - modifier), the progress bar cannot indicate how close to completion - the transfer is, so it will just move left and right to indicate - that data is moving - or, with **\--gauge**, the bar will indicate - the current rate as a percentage of the maximum rate seen so far. - -**-t, \--timer** - -: Turn the timer on. This will display the total elapsed time that - **pv** has been running for. - -**-e, \--eta** - -: Turn the ETA timer on. This will attempt to guess, based on current - transfer rates and the total data size, how long it will be before - completion. The countdown is prefixed with \"ETA\". This option will - have no effect if the total data size cannot be determined. - -**-I, \--fineta** - -: Turn the ETA timer on, but display the estimated local time at which - the transfer will finish, instead of the amount of time remaining. - When the estimated time is more than 6 hours in the future, the date - is shown as well. The time is prefixed with \"FIN\" for finish time. - As with **\--eta**, this option will have no effect if the total - data size cannot be determined. - -**-r, \--rate** - -: Turn the rate counter on. This will display the current rate of data - transfer. The rate is shown in square brackets \[\]. - -**-a, \--average-rate** - -: Turn the average rate counter on. This will display the current - average rate of data transfer (default: last 30s, see **-m**). The - average rate is shown in brackets (). - -**-b, \--bytes** - -: Turn the total byte counter on. This will display the total amount - of data transferred so far. - -**-8, \--bits** - -: Display the total bits instead of the total bytes. The output suffix - will be \"b\" instead of \"B\". - -**-k, \--si** - -: Display and interpret suffixes as multiples of 1000 rather than the - default of 1024. Note that this only takes effect on options after - this one, so for consistency, specify this option first. - -**-T, \--buffer-percent** - -: Turn on the transfer buffer percentage display. This will show the - percentage of the transfer buffer in use - but see the caveat under - **%T** in the **FORMATTING** section below. Implies **-C**. The - transfer buffer percentage is shown in curly brackets {}. - -**-A NUM, \--last-written NUM** - -: Show the last *NUM* bytes written - but see the caveat under **%nA** - in the **FORMATTING** section below. Implies **-C**. - -**-F FORMAT, \--format FORMAT** - -: Ignore the options **-p**, **-t**, **-e**, **-r**, **-a**, **-b**, - **-T**, and **-A**, and instead use the format string *FORMAT* to - determine the output format. See the **FORMATTING** section below. - -**-x SPEC, \--extra-display SPEC** - -: As well as displaying progress to the terminal, also write it to - *SPEC*. The *SPEC* must start with a comma-separated list of - destinations, and can optionally be followed by a colon and a format - string. The destinations can be **windowtitle** or **window** for - the xterm window title, and **processtitle**, **proctitle**, - **process**, or **proc** for the process title displayed by - **ps**(1). If a format string is not supplied, the same format is - used as for the terminal. For example, - "**-x \'window,process:%t %b %r\'**" will show the elapsed time, - bytes transferred, and rate, in both the window title and the - process title. - -**-v, \--stats** - -: At the end of the transfer, write an additional line showing the - transfer rate minimum, maximum, mean, and standard deviation. The - values are always in bytes per second (or bits, with **-8**). - -**-n, \--numeric** - -: Numeric output. Instead of giving a visual indication of progress, - **pv** will give an integer percentage, one per line, on standard - error, suitable for piping (via convoluted redirection) into - **dialog**(1). Note that **-f** is not required if **-n** is being - used. - -: If **\--numeric** is in use, then adding **\--bytes** will cause the - number of bytes processed so far to be output instead of a - percentage; if **\--line-mode** is also in use as well as - **\--bytes** and **\--numeric**, then instead of bytes or a - percentage, the number of lines so far is output. If **\--rate** is - added, then the transfer rate is also output (if **\--bytes** is in - use as well, the rate comes after the byte/line count). If - **\--timer** is also added, then each output line is *prefixed* with - the elapsed time so far, as a decimal number of seconds. - -**-q, \--quiet** - -: No output. Useful if the **-L** option is being used on its own to - just limit the transfer rate of a pipe. - -# OUTPUT MODIFIERS - -**-W, \--wait** - -: Wait until the first byte has been transferred before showing any - progress information or calculating any ETAs. Useful if the program - you are piping to or from requires extra information before it - starts, eg piping data into **gpg**(1) or **mcrypt**(1) which - require a passphrase before data can be processed. - -**-D SEC, \--delay-start SEC** - -: Wait until *SEC* seconds have passed before showing any progress - information, for example in a script where you only want to show a - progress bar if it starts taking a long time. Note that this can be - a decimal such as 0.5. - -**-s SIZE, \--size SIZE** - -: Assume the total amount of data to be transferred is *SIZE* bytes - when calculating percentages and ETAs. The same suffixes of \"k\", - \"m\" etc can be used as with **-L**. - -: If *SIZE* starts with **@**, the size of file whose name follows the - **@** will be used. - -: Note that **\--size** has no effect if used with **-d ***PID* to - watch all file descriptors of a process, but will work with **-d - PID:FD**. - -**-g, \--gauge** - -: If the progress bar is shown but the size is not known, then instead - of moving the bar left and right to show progress, show the current - transfer rate as a percentage of the maximum rate seen so far. - -**-l, \--line-mode** - -: Instead of counting bytes, count lines (newline characters). The - progress bar will only move when a new line is found, and the value - passed to the **-s** option will be interpreted as a line count. - -: If this option is used without **-s**, the \"total size\" (in this - case, total line count) is calculated by reading through all input - files once before transfer starts. If any inputs are pipes or - non-regular files, or are unreadable, the total size will not be - calculated. - -**-0, \--null** - -: Count lines as terminated with a null byte instead of with a - newline. This option implies \--line-mode. - -**-i SEC, \--interval SEC** - -: Wait *SEC* seconds between updates. The default is to update every - second. Note that this can be a decimal such as 0.1. - -**-m SEC, \--average-rate-window SEC** - -: Compute current average rate over a *SEC* seconds window for average - rate and ETA calculations (default 30 seconds). - -**-w WIDTH, \--width WIDTH** - -: Assume the terminal is *WIDTH* characters wide, instead of trying to - work it out (or assuming 80 if it cannot be guessed). If this option - is used, the output width will not be adjusted if the width of the - terminal changes while the transfer is running. - -**-H HEIGHT, \--height HEIGHT** - -: Assume the terminal is *HEIGHT* rows high, instead of trying to work - it out (or assuming 25 if it cannot be guessed). If this option is - used, the output height will not be adjusted if the height of the - terminal changes while the transfer is running. - -**-N NAME, \--name NAME** - -: Prefix the output information with *NAME*. Useful in conjunction - with **-c** if you have a complicated pipeline and you want to be - able to tell different parts of it apart. - -**-f, \--force** - -: Force output. Normally, **pv** will not output any visual display if - standard error is not a terminal. This option forces it to do so. - -**-c, \--cursor** - -: Use cursor positioning escape sequences instead of just using - carriage returns. This is useful in conjunction with **-N** (name) - if you are using multiple **pv** invocations in a single, long, - pipeline. - -# DATA TRANSFER MODIFIERS - -**-o FILE, \--output FILE** - -: Write data to *FILE* rather than standard output. If the file - already exists, it will be truncated. - -**-L RATE, \--rate-limit RATE** - -: Limit the transfer to a maximum of *RATE* bytes per second. A suffix - of \"K\", \"M\", \"G\", or \"T\" can be added to denote kibibytes - (\*1024), mebibytes, and so on. If **\--si** was also passed, - suffixes will denote kilobytes (\*1000), megabytes, etc. Note the - caveat about the positioning of **\--si .** - -**-B BYTES, \--buffer-size BYTES** - -: Use a transfer buffer size of *BYTES* bytes. A suffix of \"K\", - \"M\", \"G\", or \"T\" can be added to denote kibibytes (\*1024), - mebibytes, and so on. The default buffer size is the block size of - the input file\'s filesystem multiplied by 32 (512KiB max), or - 400KiB if the block size cannot be determined. This can be useful on - platforms like MacOS which perform better in pipelines with specific - buffer sizes such as 1024. Implies **-C**. - -**-C, \--no-splice** - -: Never use **splice**(2), even if it would normally be possible. The - **splice**(2) system call is a more efficient way of transferring - data from or to a pipe than regular **read**(2) and **write**(2), - but means that the transfer buffer may not be used. This prevents - **-A** and **-T** from working, cannot work with **-X**, and makes - **-B** redundant, so using **-A**, **-T**, **-X**, or **-B** - automatically switches on **-C**. Switching on **-C** results in a - small loss of transfer efficiency. (This option has no effect on - systems where **splice**(2) is unavailable). - -**-E, \--skip-errors** - -: Ignore read errors by attempting to skip past the offending - sections. The corresponding parts of the output will be null bytes. - At first only a few bytes will be skipped, but if there are many - errors in a row then the skips will move up to chunks of 512. This - is intended to be similar to **dd conv=sync,noerror** but has not - been as thoroughly tested. - -: Specify **-E** twice to only report a read error once per file, - instead of reporting each byte range skipped. - -**-Z BYTES, \--error-skip-block BYTES** - -: When ignoring read errors with **-E**, instead of trying to - adaptively skip by reading small amounts and skipping progressively - larger sections until a read succeeds, move to the next file block - of *BYTES* bytes as soon as an error occurs. There may still be some - shorter skips where the block being skipped coincides with the end - of the transfer buffer. - -: This option can only be used with **-E** and is intended for use - when reading from a block device, such as **-E -Z 4K** to skip in 4 - kibibyte blocks. This will speed up reads from faulty media, at the - expense of potentially losing more data. - -**-S, \--stop-at-size** - -: If a size was specified with **-s**, stop transferring data once - that many bytes have been written, instead of continuing to the end - of input. - -**-Y, \--sync** - -: After every write operation, synchronise the buffer caches to disk - - see **fdatasync**(2). This has no effect when the output is a pipe. - Using **-Y** may improve the accuracy of the progress bar when - writing to a slow disk. - -**-K, \--direct-io** - -: Set the **O_DIRECT** flag on all inputs and outputs, if it is - available. This will minimise the effect of caches, at the cost of - performance. Due to memory alignment requirements, it also may cause - read or write failures with an error of \"Invalid argument\", - especially if reading and writing files across a variety of - filesystems in a single **pv** call. Use this option with caution. - -**-X, \--discard** - -: Instead of transferring input data to standard output, discard it. - This is equivalent to redirecting standard output to */dev/null*, - except that **write**(2) is never called. Implies **-C**. - -**-U FILE, \--store-and-forward FILE** - -: Instead of passing data through immediately, do it in two stages - - first read all input and write it to *FILE*, and then once the input - is exhausted, read all of *FILE* and write it to the output. *FILE* - remains in place afterwards, unless it is \"**-**\", in which case - **pv** creates a temporary file for this purpose, and automatically - removes it afterwards. - -: This can be useful if you have a pipeline which generates data (your - input) quickly but you don\'t know the size, and you wish to pass it - to some slower process, once all of the input has been generated and - you know its size, so you can see its progress. Note that when doing - this with relatively small amounts of data, **\--no-splice** may be - preferable so that pipe buffering doesn\'t affect the progress - display. - -**-d PID\[:FD\], \--watchfd PID\[:FD\]** - -: Instead of transferring data, watch file descriptor *FD* of process - *PID*, and show its progress. The **pv** process will exit when *FD* - either changes to a different file, changes read/write mode, or is - closed; other data transfer modifiers - and remote control - may not - be used with this option. - -: If only a *PID* is specified, then that process will be watched, and - all regular files and block devices it opens will be shown with a - progress bar. The **pv** process will exit when process *PID* exits. - -**-R PID, \--remote PID** - -: If *PID* is an instance of **pv** that is already running, **-R - ***PID* will cause that instance to act as though it had been given - this instance\'s command line instead. For example, if **pv -L - 123K** is running with process ID 9876, then running **pv -R 9876 -L - 321K** will cause it to start using a rate limit of 321KiB instead - of 123KiB. Note that some options cannot be changed while running, - such as **-c**, **-l**, **-f**, **-D**, **-E**, and **-S**. - -# GENERAL OPTIONS - -**-P FILE, \--pidfile FILE** - -: Save the process ID of **pv** in *FILE*. The file will be replaced - if it already exists, and will be removed when **pv** exits. While - **pv** is running, it will contain a single number - the process ID - of **pv** - followed by a newline. - -**-h, \--help** - -: Print a usage message on standard output and exit successfully. - -**-V, \--version** - -: Print version information on standard output and exit successfully. - -# FORMATTING - -If the **-F** option is given, then the output format is determined by -the given format string. Within that string, the following sequences can -be used: - -**%p** - -: Progress bar. Expands to fill the remaining space. Should only be - specified once. Equivalent to **-p**. - -**%t** - -: Elapsed time. Equivalent to **-t**. - -**%e** - -: ETA as time remaining. Equivalent to **-e**. - -**%I** - -: ETA as local time at which the transfer will finish. Equivalent to - **-I**. - -**%r** - -: Current data transfer rate. Equivalent to **-r**. - -**%a** - -: Average data transfer rate. Equivalent to **-a**. - -**%b** - -: Bytes transferred so far (or lines if **-l** was specified). - Equivalent to **-b**. If **\--bits** was specified, **%b** shows the - bits transferred so far, not bytes. - -**%T** - -: Percentage of the transfer buffer in use. Equivalent to **-T**. - Shows \"{\-\-\--}\" if the transfer is being done with - **splice**(2), since splicing to or from pipes does not use the - buffer. - -**%nA** - -: Show the last **n** bytes written (e.g. **%16A** for the last 16 - bytes). Shows only dots if the transfer is being done with - **splice**(2), since splicing to or from pipes does not use the - buffer. - -**%N** - -: Name prefix given by **-N**. Padded to 9 characters with spaces, and - suffixed with :. - -**%%** - -: A single %. - -The format string equivalent of turning on all display switches is -**\`%N %b %T %t %r %a %p %e %I\'**. - -# COMMON SWITCHES - -Some suggested common switch combinations: - -**pv -ptebar** - -: Show a progress bar, elapsed time, estimated completion time, byte - counter, average rate, and current rate. - -**pv -betlap** - -: Show a progress bar, elapsed time, estimated completion time, line - counter, and average rate, counting lines instead of bytes. - -**pv -btrpg** - -: Show the amount transferred, elapsed time, current rate, and a gauge - showing the current rate as a percentage of the maximum rate seen - - useful in a pipeline where the total size is unknown. (If the size - *is* known, these options will show the percentage completion - instead of the rate gauge). - -**pv -t** - -: Show only the elapsed time - useful as a simple timer, e.g. **sleep - 10m \| pv -t**. - -**pv -pterb** - -: The default behaviour: progress bar, elapsed time, estimated - completion time, current rate, and byte counter. - -On MacOS, it may be useful to specify **-B 1024** in a pipeline, as this -may improve performance. - # EXIT STATUS -An exit status of 1 indicates a problem with the **-R** or **-P** -options. +An exit status of 1 indicates a problem with the "**\--remote**" or +"**\--pidfile**" options. Any other exit status is a bitmask of the following: @@ -602,79 +597,75 @@ The following environment variables may affect **pv**: **HOME** -: The current user\'s home directory. This may be used by the remote - control mechanism (the **\--remote** option) to exchange messages - between **pv** instances: if the */run/user/UID/* directory does not - exist (where *UID* is the current user ID), then *\$HOME/.pv/* will - be used instead. +: The current user\'s home directory. This may be used by + "**\--remote**" to exchange messages between **pv** instances: if + the */run/user/UID/* directory does not exist (where *UID* is the + current user ID), then *\$HOME/.pv/* will be used instead. **TMPDIR**, **TMP** : The directory to create per-tty lock files for the terminal when - using the **\--cursor** option. If **TMPDIR** is set to a non-empty - value, it is the directory under which lock files are created. - Otherwise, if **TMP** is set, then it is used; and if neither are - set, then */tmp* is used. + using "**\--cursor**". If **TMPDIR** is set to a non-empty value, it + is the directory under which lock files are created. Otherwise, + **TMP** is used. If neither are set, then */tmp* is used. -# AUTHOR +# NOTES -Written by Andrew Wood, with patches submitted by various other people. -Please see the package\'s ACKNOWLEDGEMENTS file for a complete list of -contributors. +In some versions of **bash**(1) and **zsh**(1), the construct +"**\<(pv filename)**" will not output any progress to the terminal when +run from an interactive shell, due to the subprocess being run in a +separate process group from the one that owns the terminal. In these +cases, use "**\--force**". -# KNOWN PROBLEMS +If **pv** is used in a pipeline in **zsh** version 5.8, and the last +command in the pipeline is based on shell builtins, **zsh** takes +control of the terminal away from **pv**, preventing progress from being +displayed. For example, this will produce no progress bar: -The following problems are known to exist in **pv**: + pv InputFile | { while read -r line; do sleep 0.1; done; } -- In some versions of **bash**(1) and **zsh**(1), the construct - **\<(pv filename)** will not output any progress to the terminal - when run from an interactive shell, due to the subprocess being run - in a separate process group from the one that owns the terminal. In - these cases, use **\--force**. +To work around this, put the last commands of the pipeline in normal +brackets to force the use of a subshell: -- If **pv** is used in a pipeline in **zsh** version 5.8, and the last - command in the pipeline is based on shell builtins, **zsh** takes - control of the terminal away from **pv**, preventing progress from - being displayed. For example, this will produce no progress bar: + pv InputFile | ( while read -r line; do sleep 0.1; done; ) - pv InputFile | { while read -r line; do sleep 0.1; done; } +Refer to [issue #105](https://codeberg.org/a-j-wood/pv/issues/105) for +full details. - To work around this, put the last commands of the pipeline in normal - brackets to force the use of a subshell: +The "**\--remote**" option requires that either */run/user/\/* or +*\$HOME/* can be written to, for inter-process communication. - pv InputFile | ( while read -r line; do sleep 0.1; done; ) +The "**\--size**" option has no effect if used with +"**\--watchfd** *PID*" to watch all file descriptors of a process, but +will work with "**\--watchfd** *PID*:*FD*" to watch a single file +descriptor. - Refer to [issue #105](https://codeberg.org/a-j-wood/pv/issues/105) - for full details. - -- The **-c** option does not work properly on Cygwin without - **cygserver** running, if started near the bottom of the screen (IPC - is needed to handle the terminal scrolling). To fix this, start - **cygserver** before using **pv -c**. - -- The **-R** option requires that either **/run/user/\/** or - **\$HOME/** can be written to, for inter-process communication. - -If you find any other problems, please report them. +If the input size cannot be calculated, and the output is a block +device, then **pv** will read the output device\'s size, use that as if +it had been passed to "**\--size**", and activate "**\--stop-at-size**". # REPORTING BUGS Please report any bugs to **pv@ivarch.com**. -Alternatively, use the issue tracker linked from the [pv home +Alternatively, use the issue tracker linked from the [**pv** home page](https://www.ivarch.com/programs/pv.shtml). # SEE ALSO -**cat**(1), **dialog**(1), **splice**(2), **open**(2) (for **O_DIRECT**) +**cat**(1), **dialog**(1), **splice**(2), **fdatasync**(2), **open**(2) +(for **O_DIRECT**) # COPYRIGHT Copyright © 2002-2008, 2010, 2012-2015, 2017, 2021, 2023-2024 Andrew Wood. -License GPLv3+: GNU GPL version 3 or later -\. +License GPLv3+: [GNU GPL version 3 or +later](https://www.gnu.org/licenses/gpl-3.0.html). This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. + +Please see the package\'s ACKNOWLEDGEMENTS file for a complete list of +contributors. diff --git a/src/main/help.c b/src/main/help.c index be34ac2..7724259 100644 --- a/src/main/help.c +++ b/src/main/help.c @@ -298,18 +298,9 @@ void display_help(void) { "-a", "--average-rate", NULL, N_("show data transfer average rate counter"), { 0, 0, 0, 0} }, - { "-m", "--average-rate-window", N_("SEC"), - N_("compute average rate over past SEC seconds (default 30s)"), - { 0, 0, 0, 0} }, { "-b", "--bytes", NULL, N_("show number of bytes transferred"), { 0, 0, 0, 0} }, - { "-8", "--bits", NULL, - N_("show number of bits transferred"), - { 0, 0, 0, 0} }, - { "-k", "--si", NULL, - N_("treat suffixes as multiples of 1000 rather than 1024"), - { 0, 0, 0, 0} }, { "-T", "--buffer-percent", NULL, N_("show percentage of transfer buffer in use"), { 0, 0, 0, 0} }, @@ -332,6 +323,12 @@ void display_help(void) N_("do not output any transfer information at all"), { 0, 0, 0, 0} }, { "", NULL, NULL, NULL, { 0, 0, 0, 0} }, + { "-8", "--bits", NULL, + N_("show number of bits transferred"), + { 0, 0, 0, 0} }, + { "-k", "--si", NULL, + N_("treat suffixes as multiples of 1000 rather than 1024"), + { 0, 0, 0, 0} }, { "-W", "--wait", NULL, N_("display nothing until first byte transferred"), { 0, 0, 0, 0} }, @@ -353,6 +350,9 @@ void display_help(void) { "-i", "--interval", N_("SEC"), N_("update every SEC seconds"), { 0, 0, 0, 0} }, + { "-m", "--average-rate-window", N_("SEC"), + N_("compute average rate over past SEC seconds (default 30s)"), + { 0, 0, 0, 0} }, { "-w", "--width", N_("WIDTH"), N_("assume terminal is WIDTH characters wide"), { 0, 0, 0, 0} }, @@ -402,6 +402,9 @@ void display_help(void) { "-U", "--store-and-forward", N_("FILE"), N_("write all input to FILE before writing to output"), { 0, 0, 0, 0} }, + { "-d", "--watchfd", N_("PID[:FD]"), + N_("watch file FD opened by process PID"), + { 0, 0, 0, 0} }, #ifdef SIGINFO_PROVIDES_PID { "-R", "--remote", N_("PID"), N_("update settings of process PID"), @@ -411,11 +414,6 @@ void display_help(void) { "-P", "--pidfile", N_("FILE"), N_("save process ID in FILE"), { 0, 0, 0, 0} }, - { "", NULL, NULL, NULL, { 0, 0, 0, 0} }, - { "-d", "--watchfd", N_("PID[:FD]"), - N_("watch file FD opened by process PID"), - { 0, 0, 0, 0} }, - { "", NULL, NULL, NULL, { 0, 0, 0, 0} }, { "-h", "--help", NULL, N_("show this help and exit"), { 0, 0, 0, 0} },