Context: I was attempting to compress a fairly big (16Gb) file with bzip2, but had no idea of how much time it would take.
The solution I came up with isn't perfect, since it doesn't show an actual percentage, but it still gives an idea of what's going on, since it prints the compressed file's current size, along with the elapsed time.
The 1st page gives a few commands that might work on Linux, but don't work on my Mac, though I use Bash.
The solution came from the little screenshot shown on PV's home page:
My use case is much simpler than the command demonstrated above. Here's the command, followed by a breakdown:
cat macOS.vdi | bzip2 | pv -cN bzip2 > macOS.vdi.bz2
-
Dump the file to compress
-
Pipe it to
bzip2
-
Pipe it to Pipe Viewer. From
man pv
:-c
or--cursor
is for "Use cursor positioning escape sequences".-N NAME
or--name NAME
is for "Prefix the output information withNAME
", and is useful if you're monitoring multiple pipe entries with pv, such as in the screenshot above. I could have gone without it.
-
Last but not least, redirect the compressed data to a file (otherwise you end up displaying a huge amount of garbage in your terminal).