pv (progress bar) and gzip

What are you trying to achieve is to see the progress bar of the compression process. But it is not possible using pv. It shows only transfer progress, which you can achieve by something like this (anyway, it is the first link in the google):

pv input_file | gzip > compressed_file

The progress bar will run fast, and then it will wait for compression, which is not observable anymore using pv.

But you can do that other way round and watch the output stream, bot here you will not be able to see the actual progress, because pv does not know the actual size of the compressed file:

gzip input_file | pv > compressed_file

The best I found so far is the one from commandlinefu even with rate limiting and compression of directories:

$D=directory
tar pcf - $D | pv -s $(du -sb $D | awk '{print $1}') --rate-limit 500k | gzip > target.tar.gz

Yes, it is kinda possible using the lines of the file, not the bytes. You get an accurate enough progress bar:

cat input_file | pv -ls $( wc -l input_file ) | gzip -c -- > compressed_file