

GCP - cp with a progress bar - dannyrosen
http://www.hecticgeek.com/2012/03/gcp-command-line-file-copy-ubuntu-linux/
Nifty, lightweight copy tool. Completely replace cp with: alias cp=&quot;&#x2F;usr&#x2F;bin&#x2F;gcp&quot;
======
Game_Ender
For single files or monitoring other pipe based operations (like network
transfers) pv [1] is also a useful tool.

1 -
[http://www.ivarch.com/programs/pv.shtml](http://www.ivarch.com/programs/pv.shtml)

~~~
baiitsu
Using pv:

    
    
      gcp() {
        cat "$1" | pv | cat > "$2"
      }

~~~
gcmalloc
useless use of cat

    
    
        pv < "$1" > "$2"

~~~
nitrogen
Even if the _cat_ at the beginning of a pipe isn't strictly necessary, it
still helps readability to have everything flowing from left to right.

~~~
emillon
I also advocate this "useless" use of cat, but you can write the redirection
before the command:

    
    
        <"$1" pv >"$2"

------
coherentpony
The 'g' prefix is a bad idea. On BSD systems that prefix is used to refer to
binaries in the GNU toolset.

~~~
theOnliest
I'd recommend "pcp," for "progress copy"...I'd use it for the name alone!

------
_JamesA_
Why? rsync does all of this and a whole lot more.

~~~
protomyth
He didn't want all the complication of rsync, he just wanted something simple
with a progress bar. Rsync isn't really that simple. Sure, he could of wrote a
shell script on top of rsync, but he probably learned a lot more from this.

~~~
fragmede
For local copies, rsync with a progress meter is as simple as

    
    
      rsync --progress <source> <destination>

~~~
johnchristopher
I usually use it like this for local copy:

    
    
        rsync -rvh --progress <source> <destination>

~~~
elementai
Oh-my-zsh has a plugin 'cp' which is basically an alias: alias cpv="rsync
-poghb --backup-dir=/tmp/rsync -e /dev/null --progress --"

------
mhugo
This one is also pretty clever (based on catching the write() syscall with
strace) : [https://chris-lamb.co.uk/posts/can-you-get-cp-to-give-a-
prog...](https://chris-lamb.co.uk/posts/can-you-get-cp-to-give-a-progress-bar-
like-wget)

~~~
lamby
Thanks.

------
ck2
I think someone made a patch which works with the original gnu coreutils

Oh here it is
[http://beatex.org/web/advancedcopy.html](http://beatex.org/web/advancedcopy.html)

------
Zecc
This seems relevant:

[http://www.commandlinefu.com/commands/view/4553/copy-a-
file-...](http://www.commandlinefu.com/commands/view/4553/copy-a-file-using-
dd-and-watch-its-progress)

dd does not show a progress bar, unfortunately but it does report its
progress.

------
joelthelion
Shouldn't cp have "-h" (human readable) flag that does exactly that?

~~~
icebraining
_UNIX Style, or cat -v Considered Harmful_ :
[http://harmful.cat-v.org/cat-v/](http://harmful.cat-v.org/cat-v/)

~~~
joelthelion
That's not an argument. There's no reason why cp shouldn't report progress if
you want to. Not one.

------
2bluesc
SCP works locally too and has a progress bar.

~~~
rquirk
scp just falls back to cp when copying locally, so doesn't show any progress
bar.

------
k_bx
If you use oh-my-zsh, gcp is binded to "git cherry-pick" (with auto-completion
etc.), so I did:

    
    
        sudo ln -s /usr/bin/gcp /usr/local/bin/cp_

------
vikas0380
A good alternative to cp.

