How to Copy at Command Line Showing Progress & Speed Indicator

Nov 9, 2020 - 5 Comments

Mac Terminal icon

Ever wished you could see the transfer progress and speed of copying files at the command line? If you’re familiar with the command line of Mac OS, Linux, or any other Unix operating system, you likely use the ‘cp’ or ditto commands to copy files, directories, and other data. The ditto and cp command is great, but one downside is that cp does not include a progress indicator, and that’s what we’re going to resolve here by creating an alias to use an rsync command with a progress indicator to copy data at the command line.


Obviously this is aimed at advanced users who use the command line for copying data, and who are comfortable with the concept of creating and using aliases within Terminal. If you’re a more novice user you’d probably be better off simply copying in Finder, duplicating files in the Mac Finder (which shows a visual progress bar), or using copy, cut, and paste for files in Mac Finder too.

How to Copy with a Progress & Speed Indicator at the Command Line on Mac

Again, we’ll be using rsync and an alias to create an alternate copy command with a transfer progress and speed indicator. This is covered with MacOS in mind, but it works the same with any other unix or Linux platform.

The basic rsync command we will use is as follows:

rsync -r --progress

But to make it easy to use again in the future repeatedly, we’re going to create an alias, so that ‘pcp’ will copy data with a progress indicator. Thus, the command becomes:

alias pcp="rsync -r --progress"

Assuming you use zsh (as most modern MacOS releases do, unless you changed your shell), you can add that to your .zshrc file as well to continue to use the copy with progress command.

Once the alias has been established, you can use the pcp command to copy and monitor the progress of the data copy. For example, you might try something like:

pcp ~/Downloads/GiantISO.iso /Volumes/Backups/GiantISO-backup.iso

You will see a progress indicator while copying with a percentage of the file copy, the data transfer rate, and time.

copy while showing progress indicator and speed at command line

You can also use this with directories too, like so:

pcp /Backups/ImportantStuff /Backups2/

Again, you’ll see a progress indicator with percentage completed of the data copy, transfer rate, and time elapsed.

This is a super handy tip discovered on Twitter, cheers to @hoyd for sharing this, you can follow us on Twitter too if you’re into that sort of thing. If you have any additional tips, recommendations, suggestions, or alternatives to this approach to copying while showing progress and speed at the command line, share them with us in the comments.

If you enjoyed this tip, don’t miss our large archive of command line tips and tricks, there’s plenty more to learn!

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS X, Tips & Tricks

5 Comments

» Comments RSS Feed

  1. Damon says:

    Using ⌃T (hold control-key and press T) sends a SIGINFO to the cp command which shows its status.

    Not terribly well documented anywhere, but https://stuff-things.net/2016/04/06/that-one-stupid-dd-trick-and-the-ballad-of-siginfo/ is a decent read.

  2. Daniel says:

    Thanks for this tip. I’m pretty good (not great) with command-line stuff and it is frustrating when copying not to know how long something is going to take or if something went wrong and things look as though they might have froze.

  3. jnight310 says:

    hi all. i’d suggest using this instead:

    rsync -aX –progress

    a flag is for archive, which implies all these: -rlptgoD
    X = preserves extended attributes.
    l = keep aliases/symlinks as they are
    p = keep permissions
    t= preserve mod times
    etc

  4. Name says:

    Perhaps of interest as well:

    pv – monitor the progress of data through a pipe

    https://linux.die.net/man/1/pv

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site