Way back in 2009 I wrote a post about how to display progress bars in Powershell. The same thing is possible in bash with pv. If it’s not available in your shell just do…

yum install pv

Or equivalent for your platform. The following example compresses a file into a tar archive reporting progress with a bar…

tar cf - mongodb-linux-x86_64-2.6.10.tgz | pv -s 116654065 | gzip -9 > rhys.tar.gz

Breaking this down…

tar cf - "file to compress" | pv -s "size of file to compress (bytes)" | gzip -9 > "gz archive to create"

This will show a progress bar looking something like…

111MiB 0:00:05 [20.7MiB/s] [==================================================================================================>] 100%

You can display integer numbers for percentage progress in you prefer. Just do…

tar cf - mongodb-linux-x86_64-2.6.10.tgz | pv -s 116654065 -n | gzip -9 > rhys.tar.gz

Output…

17
36
53
71
89
100