How to Copy at Command Line Showing Progress & Speed Indicator
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.
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!