Extended Cp and Mv Commands
All command line geeks know cp and mv commands. Especially while copying/moving large files or many files these commands won’t verbose anything. So you can’t estimate when the job will be finished and watch current progress.
My suggestion is to use rsync as a replacement of those commands. By using bash_aliases file, we can create short aliases like cpx and mvx and encapsulate rsync details. (x is abbreviation of extended. I don’t want to override original cp and mv, so I can use orignal ones if necessary.)
First open your favorite text editor and add these lines to your ~/.bash_aliases file:
If your home directory doesn’t contain hidden bash_aliases file, create a new one.
To enable changes immediately without logout and login to terminal again:
a
will keep permissions and other file attributes.h
will make output human readable. (size, speed etc.)--progress
will show progress.--remove-sent-files
transforms our cp command to mv command.
Example, copying a large file:
Example, moving a large file:
Example, copying a directory with some files inside:
Example, moving a directory with some files inside:
Note: --remove-sent-files
tells rsync to remove from the sending side the files (meaning non-directories) that are a part of the transfer and have been successfully duplicated on the receiving side. So empty directories will be left. Yo should remove them with rm -Rf
command.
Columns: (output of rsync) filename MB-copied MB-speed time-remaining
Happy coding.