OYB software, shell

Copy with a progress bar with cpv

It won’t come as a surprise by now that we love shell progress bars.

When we are copying big files it would be nice to have an ETA, progress bar and some feedback, but the cp command doesn’t provide us with this.

Of course, we can use rsync to get some feedback of the process, but if we want a progress bar probably the most simple way is using pv.

pv, or pipe viewer is a very neat shell tool that allows you to monitor a pipe. It is invoked in a way that is similar to the cat command. You can pipe to it and monitor the throughput of the data that goes through the pipe

You can also open a file directly with it, just like cat. This is in fact how you would “copy” a file using pv

But that syntax is not very nice to use, plus it is limited to a single file at a time. I wanted to use it with whole directories, recursively so I came up with a little wrapper, with the astoundingly original name cpv.


Invoke just like cp. No options. Obviously requires that you have pv installed.

That’s it. It is really a very simple wrapper but it is handy.

It is also useful when copying from or to network mounts to measure the transfer speed.


Add the code to your .zshrc or .bashrc. You can do this in one line, but inspect it first so you don’t have to trust me blindly.

More cool stuff with pv

You can do much more that copying. You can get data about just about anything that uses files or pipes.

You can for instance monitor that netcat transfer

Or the creation of that tarball

Or a docker export

Or that ssh pipe

Or that database dump

You can flash a SD card with progress (even though we finally have dd status=progress )

Zero a drive

It can even track open file descriptors, so you can monitor the operation afterwards the process started


Check out other shell articles

Author: nachoparker

Humbly sharing things that I find useful [ github dockerhub ]

7 Comments on “Copy with a progress bar with cpv

Leave a Reply

Your email address will not be published. Required fields are marked *