Rob's answer is great for most situations, but Pipe Viewer doesn't work well in use cases where a tty isn't available, like when monitoring a mysql docker container's initialization output or when you want to log the progress to a file.
Pipe Monitor (github) is an alternative designed to output updates to a log stream via STDERR. Disclaimer: I am the author.
Their basic functionality is very similar: Read from STDIN or a file. Pipe the contents to STDOUT. Show progress. However, whereas Pipe View uses terminal control sequences to update a visual progress bar on a single line, Pipe Monitor outputs text updates appropriate for non terminal applications.
Pipe Monitor supports the following basic options. Output is customizable via the --format option:
Usage: pm [--size SIZE] [--name NAME] [--format FORMAT] INPUT_FILE
Positional arguments:
INPUT_FILE Optional input file. If not provided input will be read from STDIN
Options:
--size SIZE, -s SIZE Size of input from STDIN. Ignored if using INPUT_FILE
--name NAME, -n NAME A NAME tag for this output. Will be pre-pended to default FORMAT string
--format FORMAT, -f FORMAT
Output format string. Allowed keys: %name, %size, %time, %eta, %percent, %written, %buffered
--help, -h display this help and exit
Here is a comparison of the output of each in a non terminal environment.
Pipe Viewer (non terminal):
$ pv -nf testin > testout
40
70
77
84
90
96
100
Pipe Monitor:
$ pm testin > testout
Processed 0 bytes of 2456678400 (0% complete). 0 bytes buffered. Running 0s, eta: <unknown>
Processed 1750794240 bytes of 2456678400 (71% complete). 327680 bytes buffered. Running 2s, eta: 1s
Processed 2106937344 bytes of 2456678400 (85% complete). 700416 bytes buffered. Running 4s, eta: 1s
Processed 2419339264 bytes of 2456678400 (98% complete). 2871296 bytes buffered. Running 6s, eta: 0s
Processed 2456678400 bytes of 2456678400 (100% complete). 0 bytes buffered. Running 6s, eta: 0s