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:
 ~/.profile
alias cp2='rsync -aPWh'


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


...and the results look like this:
rsync_cp.png




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

-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.