Home Command line utilities gcp – An Advanced File Copier Utility For Linux

gcp – An Advanced File Copier Utility For Linux

By sk
Published: Last Updated on 10.1K views

Most of you have noticed that the cp command won't display the copy progress while copying files/folders. When I am copying a large file with cp command, I really have no idea 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. Not anymore! Here is where gcp utility comes in help. The 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.

Unlike the cp command, the gcp utility 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 problematic file from copying and copy the next files.
  • It can copy both single or multiple files or folders.
  • gcp logs all its action. So, we can easily find 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 Linux and Unix-like operating systems.

Install gcp on Linux

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 it using any AUR helper, for example Yay.

$ yay -S python-gcp-git

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

$ yay -S python-progressbar

gcp is also available on PyPI, you can install it with Pip package manager like below:

$ pip3 install gcp

And, finally, install python-progressbar.

Debian/Ubuntu:

$ sudo apt-get install python-progressbar

How to use gcp, the advanced file copier, in Linux

gcp usage is pretty much same as cp command's.

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:

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 really 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 was copied, but something went wrong (e.g. changing the permissions of the file). FAILED means - the file was not copied.

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

$ gcp --help

Or, refer the man pages.

$ man gcp

Update:

The progress bar for cp and mv commands can be easily added using a patch named "Advanced Copy". For details, check the following link.

Advanced Copy – Add Progress Bar To cp And mv Commands In Linux

Resource:

Recommended Read:

You May Also Like

2 comments

Chris McGimpsey-Jones May 12, 2017 - 2:03 pm

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.

Reply
Kris S. June 1, 2018 - 1:10 am

Looks nice! 🙂 But what I really, really would like for an advanced cp tool, is the possibility to copy to multiple destinations (parallel), too… Starting the copies with a syntax like gcp -r SourceDir/ -d DestDir1/ DestDir2/
(For instance using -d to indicate that the listing of destinations begins)
The advantage should be that the process should only need to read once (per block) and then perform multiple copies of the read data. In the classical sequential solution you would need to read the source files once again for each copy…

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More