gcp – An Advanced File Copier Utility For Linux

gcp - An Advanced File Copier Utility For Linux

gcp (Goffi’s cp) is an advanced file copier tool, heavily inspired from the traditional cp command utility, but with some additional features. It is completely free and open source software, released under GNU General Public License. One of the issue I have often noticed while using cp command is It doesn’t display the copy progress. Say for example, when I am copying a large file, I really don’t know how long it is going to take, or what is the currently copied percentage. Other than looking at the blinking cursor icon in the Terminal and the hard drive indicator while copying large files, I have no idea whether copying progress is really going on or not. Here is where gcp comes in handy. Unlike the cp command, gcp offers the following high-level functionalities:

  • Displays the copy progress indicator, with estimated time, current file speed etc.
  • gcp continue copying even when there is an issue. It will just skip the file with problem, and go on and copy the next files.
  • It can copy both single or multiple files or folders.
  • gcp logs all its action. So, we can easily know which files have been successfully copied.
  • If you accidentally cancels a copy process, it will keep the record of it. Instead of deleting the contents, it will keep the partially copied content. You can then run the copy process again, and it will copy the rest of the files where you left it.
  • If you launch a copy when an other is already running, the files are added to the first queue, this avoid your hard drive to move its read/write head all the time.
  • You can save a list of files you copied and copy them again later from that list. It will be very useful when you want to copy the same files to multiple targets.

In this brief guide, I will show you how to install and gcp in Unix-like operating systems.

Install gcp

gcp is available in the default repositories of Debian, and Ubuntu. You can install by simply running the following command from the Terminal:

sudo apt-get install gcp

For Arch Linux, and its derivatives, It is available in AUR. So, you can install either using yaourt or packer.

yaourt -S python-gcp-git

Or,

packer -S python-gcp-git

Then, install the python-progressbar package, which is used to display the progress bar while copying files.

yaourt -S python-progressbar

Or,

packer -S python-progressbar

For other Linux distributions, you need to compile and install manually as described below.

First, you need to install python package. Since it is available in the default repositories of all Linux distributions, you can install it using the default package manager.

For instance, you can install python in DEB based systems using command:

sudo apt-get install python

Download the latest source file from this link. Extract the downloaded file, and go to the extracted folder:

cd gcp-0.1.3

Finally, run the following command to compile and install it:

sudo python setup.py install

And, finally, install python-progressbar.

Debian/Ubuntu:

sudo apt-get install python-progressbar

gcp usage

gcp usage is pretty much same as cp command.

The typical usage of gcp is;

gcp [OPTIONS] FILE DEST
gcp [OPTIONS] FILE1 [FILE2...] DEST-DIR

Let me show you some practical examples. The following command will copy the contents of Dir1 to a directory called Dir2.

gcp Dir1/video.mp4 Dir2/

Sample output would be:

Copying 876.53 MiB 100% |############################| 30.08 MB/s Time: 0:00:30

As you see in the above output, gcp command shows the copy progress indicator, with estimated time, current file speed etc. It will makes us easy to find what is going on.

To copy multiple files, just specify them one after the another and the target directory like below.

gcp file1 file2 Dir

To copy a folder to another folder, use -r flag like below.

gcp -r Dir1/ Dir2/

If you don;t want to see the progress bar, you can disable it using –no-progress flag.

gcp --no-progress source destination

If the target folder already has the same file, you will get the following warning message:

File [/home/sk/Dir2/video.mp4] already exists, skipping it !
/!\ THE FOLLOWING FILES WERE *NOT* SUCCESSFULY COPIED:
 - /home/sk/Dir1/video.mp4
--

Please check journal: /home/sk/.gcp/journal

You can verify the journal file whether the previous file process is successfully complete or not.

cat /home/sk/.gcp/journal

Output:

/home/sk/Dir1/video.mp4
OK:

If the output is OK, the copy process is success. If the output is PARTIAL, It means that the file is copied, but something went wrong (e.g. changing the permissions of the file). FAILED means the file is not copied.

For more details about gcp utility, run the following command:

gcp --help

Or, refer the man pages.

man gcp

Please note that gcp is still under development. You may encountered with unexpected errors. Use it at your own risk!


Recommended Read: How To Quickly Transfer Large Files Over Network In Linux And Unix


And, that’s all. I will keep you updated with interesting and useful Linux guides, tips and tricks everyday. Keep visiting OSTechNix.

Happy weekend!

Cheers!!

Resource:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You may also like...

  • Excellent tool. Thanks for making it known. Until I read this I had no idea about it. It’s similar to zsync in its verbose level, but aimed for local file copies.