Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

As great as Linux/Bash is, sometimes I wish some of the built-in commands did a little bit more than the bare minimum. Of these the 'cp' command is something that I always thought should have had a way to show progress when copying files. There are many questions about this very thing on StackExchange like this one and this one. My preferred solution is to use 'rsync' but I'm also a big fan of simplifying things and can never remember all the various command line options required. So this post shows my little trick to enabling file copy speed and percentage display when copying files.

I simply add the following line to my ~/.profile file:
alias cp2='rsync -aPWh'

Then I can do something like this...
cp2 tmpfile tmpfile2

...and the results look like this:

Lets see what those command line options all mean.
 Command Line Options
a - Archive Mode
P - Shows the progress and keeps partially copied files
W - Does not use the rsync protocol, simply copies whole files
h - Shows output in human readable format

As a bonus, since 'rsync' is used as the underlying command to copy files, you can also copy files from remote servers, much like when using 'scp'.

Here's another useful alias I've created: Add a filter/search option to the OS X Terminal history command


Hope you found this post useful...

...so please read on! I love writing articles that provide beneficial information, tips and examples to my readers. All information on my blog is provided free of charge and I encourage you to share it as you wish. There is a small favour I ask in return however - engage in comments below, provide feedback, and if you see mistakes let me know.

If you want to show additional support and help me pay for web hosting and domain name registration, donations, no matter how small, are always welcome!

Use of any information contained in this blog post/article is subject to this disclaimer.
comments powered by Disqus
Other posts you may like...