Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to copy or move from shell with progressbar

📅 2014-Aug-11 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cp, mv, progressbar ⬩ 📚 Archive

When I am copying or moving a big file or a large number of small files, I wish I could see some progress of the operation and the speed at which the operation is being performed. This can be done by using the Advanced Copy mod of the cp and mv commands, which have been patched to display a progressbar with all this information during the operation. You can either get the source code or pre-built binaries from here.

I like to use these commands by default, so I move them to /usr/local/bin:

$ sudo cp ./cp /usr/local/bin
$ sudo cp ./mv /usr/local/bin

Typically, your PATH puts /usr/local/bin ahead of /bin, so the patched versions of the commands will be executed now. Else, change your PATH to accomplish this.

To view the progressbar for a operation, use the -g option:

$ cp -g -R foo-big-file.bin /media/joe/backup/

I use the fish shell, where I have added aliases for both of these commands with progressbar display:

function cpg
    cp -g $argv
end

function mvg
    mv -g $argv
end

Tried with: Ubuntu 14.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧