Display Progress and Speed When Using ‘cp’ Command

I ran across an interesting method for getting ‘cp’ to show progress and speeds as well. Take a look at the page here:

There is some controversy to it since there is so much overhead (through strace, awk, etc), but the thought is very cool. I wonder if there’s a better way of doing this… the pv command maybe? Or a more in-depth solution?

I noticed that gnome introduced this sort of information in the copy file dialog. It get’s me wondering how they did that (and even more-so how accurate it really is).

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:

There's 2 Comments So Far

  • mlukaszek
    December 6th, 2010 at 7:21 am

    Sorry for commenting such an old post, but I have just came here googling 🙂

    I think that a lighter solution could be:

    # cat /tmp/cpv.sh
    FS=$(stat -c %s $SRC)
    cat $SRC | pv -s $FS > $DST

    Which can be then used as:
    cpv /path/to/source/file.tgz /tmp/destination.tgz

    Of course, you should check input parameters first, support DST which could be a directory, etc. but this is cosmetics mostly. You get the idea 🙂

  • [email protected]
    December 7th, 2010 at 5:02 pm

    I really appreciate the input. Never feel sorry for commenting on an old post!

Share your thoughts, leave a comment!