Advanced Copy – Modified cp Command That Shows Progress Bar

By | 02/09/2013

Have you ever felt clueless (about what is going on) while waiting for a large file to get copied through cp command? Ever wanted cp command to display progress bars and other useful information (like total time taken to copy etc)? If the answer is yes, then Advanced-Copy is the solution.

advanced-copy-main

Advanced-Copy (cp) is a command line utility which is nothing but a modified version of the original cp command that displays progress bars while copying files. This is especially useful while copying large files so that user gets an idea about the current status of the copy process.

NOTE – Looking for another cp alternative? Read our article on gcp command.

Advanced Copy (cp) Command In Linux

NOTE – All the instructions and examples presented in this article are tested on Ubuntu 13.04

A Brief Tutorial

To use advanced copy command, just add command line option -g while executing this command.

Here is an example screen-shot of a copy operation using advanced copy command:

ad-cp-1

So you can see that a couple of nice progress bars are shown while copy operation is going on. Once the copy is complete, this command displays some more useful information.

ad-cp-2

Useful information like number of files, total size, time taken and rate of transfer are displayed once the copy operation completes.

NOTE – I used ./cp rather than cp because I compiled this new advanced cp command from sources but did not copy it in standard system paths. Go through the Download/Install section for more information.

Download/Install

Here are some of the important links :

Though you can directly download the pre-compiled binaries but as recommended by the author himself, I downloaded the sources and compiled the advanced copy command from source. I used the following steps in this process :

$ wget http://ftp.gnu.org/gnu/coreutils/coreutils-8.21.tar.xz
$ tar xvJf coreutils-8.21.tar.xz
$ cd coreutils-8.21/
$ wget http://zwicke.org/web/advcopy/advcpmv-0.5-8.21.patch
$ patch -p1 -i advcpmv-0.5-8.21.patch
$ ./configure
$ make

While running the second-last step i.e., configure, I got the following error :

configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)
See `config.log' for more details.

I used the following command to solve this error :

$ export FORCE_UNSAFE_CONFIGURE=1

Other than this problem, all the other steps executed successfully. These steps also produced an advanced mv command. Just like advanced cp command, advanced mv command is also superior to original mv command in terms of the progress bar feature that it provides. Read Compile from sources section on the download page for instructions on replacing original cp/mv command with advanced cp/mv command.

Pros

  • Has same name as that of original copy command ie cp.
  • Provides status of copy operation through progress bars.
  • Provides more useful information when the copy operation completes.

Cons

  • Need to replace original cp command (from standard system path) with this command to make it globally available.
  • Compilation from sources could be required in some cases.
  • The only main feature available is the progress bar. Other features are still under development.

Conclusion

I was impressed with the progress bar feature though I feel that more such missing features should be identified and added to advanced cp command. Users need to be careful about the stability issues of advanced cp command before replacing original cp command with it. All in all, I would say that it is a good utility to have in your kitty especially if you spend a lot of time copying and shifting files through command line.

Have you ever used advanced cp or any other cp-like command line utility? Share your experience with us.

10 thoughts on “Advanced Copy – Modified cp Command That Shows Progress Bar

    1. siny

      Actualy it is “rsync -avP” (small v, at least uder openSUSE)
      Also, no need for “-P” (“–progress –partial”), –progress should be enough, and we might add “-I” not to skip over existing files with same size and mtime (to emulate cp as much as possible)

      Easy way would be:
      > alias acp=”rsync -avI –progress”
      > acp source dest

      Pros:
      available on any linux
      very well tested
      easy to setup: just add the alias= line to your ยจ/.bashrc (or other shell startup script)

      Cons:
      none :)

      Reply
  1. stampeder

    Himanshu, that’s a nice tip but covering-up the original “cp” command, which is a shell-intrinsic utility, could have very bad consequences in a single-user runlevel situation unless it can be compiled statically-linked. One solution is to rename this “advanced cp” utility to something like “cpa”, or another is to look into the “pv” (Pipe Viewer) utility that provides screen feedback for not just copying but for moving files, etc.

    http://www.ivarch.com/programs/pv.shtml

    Reply
    1. Himanshu Post author

      @stampeder

      Thanks for your comment. I agree with your point. I listed the same reason under ‘Cons’. Also, I’ll definitely take a look at “pv” utility.

      Reply
  2. TG

    You should never run any of these compilation steps as root. Please go learn why and remove these dangerous recommendations from your website.

    Reply
  3. Gyroglm

    This is not unix! No feedback = everything is OK, go get a coffee :-)
    Next you’ll want little flying folders!

    Reply
  4. dru8274

    An advanced copy already exists, with pretty progress bars et al –> “apt-get install gcp”

    $ man -k gcp
    gcp (1) – Advanced command-line file copier

    Reply
  5. Ellis

    My process went like this in case it helps someone:
    OSX 10.9 + Homebrew + Advanced Copy

    Part 1 — Advanced Copy:
    $ wget http://ftp.gnu.org/gnu/coreutils/coreutils-8.21.tar.xz
    $ tar xvJf coreutils-8.21.tar.xz
    $ cd coreutils-8.21/
    $ wget http://zwicke.org/web/advcopy/advcpmv-0.5-8.21.patch
    $ patch -p1 -i advcpmv-0.5-8.21.patch`
    x no make
    x no ./configure

    Part 2 — Homebrew [ > = output ]
    $ cd advcpmv-0.5-8.21 (the patched version from above)
    $ brew diy
    > –prefix=/usr/local/Cellar/coreutils/8.21 #copy this
    $ ./configure –without-gmp –program-prefix=g –prefix=/usr/local/Cellar/coreutils/8.21
    # the above installs just as home-brew default would
    $ make && make install
    $ brew link coreutils

    Homebrew keeps everything clean. Usage is gcp, gmv, and so on, or alias or however you want to use it, but it’s the best (user/greenhorn friendly + aesthetic) progress bar I’ve come across, wish I could apply it to everything.
    – – – –
    http://cl.ly/image/0T3V0h3S2f2Y

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *