8

Is there any specific package for cp command which shows the process of being copied.

I'm wondering if there is any package cp which shows additional information that what has been copied and what are left or how many percentage it has been copied...etc. Any body using any?

2 Answers 2

8

You can pipe things into the pv command to add progress indication to programs that might not have their own progress meter.

cp -a source/ dest/ | pv

However if I'm doing a copy large enough that I need a progress bar I end up using rsync anyway as Jeremy recommends. He also points out that you'll need to arrange your pipeline so that the data is piped though pv - the example gives only tells you how much data the cp is printing out, not how much is being copied. Something like this will work for single files: pv source > dest.

However, for copying directories, you'll need to get more complex.

5
  • A problem with apt-update 0% [Waiting for headers], once installed pv I'll get back here again.
    – user3215
    Feb 17, 2011 at 5:44
  • 2
    If you want to use pv, you'll need to arrange your pipeline so that the data is piped though pv - the example Jorge gives only tells you how much data the cp is printing out, not how much is being copied. Something like this will work for single files: pv source > dest. However, for copying directories, you'll need to get more complex. Feb 17, 2011 at 10:20
  • @Jeremy Kerr: +1 for more information
    – user3215
    Feb 17, 2011 at 12:07
  • @Jeremy Thanks for the info, I've added it into my answer, feel free to propose an edit if there's anything else you'd like clarified. Feb 17, 2011 at 14:12
  • Maybe the best solution is to just extend original cp command with progress options? github.com/goj/coreutils/blob/rm-d/src/cp.c
    – sobi3ch
    Oct 6, 2013 at 21:53
8

You can use rsync to do the copy. If you use the -P option (show progress), it does just that.

I tend to use rsync -avP <source> <dest> for most copying.

7
  • 1
    Yeah you are right and I'll use that for synchronization but the problem is with me as I'm called mistake maker. In hurry, if I exchange soruce with destination or vise versa then I'm done. I seldom use rysnc until it's necessary and I'll have to be very careful. Good answer, thanks!
    – user3215
    Feb 17, 2011 at 5:31
  • How is making a mistake with rsync any worse than making a mistake with cp?
    – djeikyb
    Feb 17, 2011 at 6:20
  • @djeikyb: what if you specify source in place of destination when using rsync?
    – user3215
    Feb 17, 2011 at 7:47
  • @djeikyb: what happens if you do the same with cp?
    – user3215
    Feb 17, 2011 at 7:48
  • If there are no files matching the command, they both fail. If there are files matching the command, they both overwrite. Correct?
    – djeikyb
    Feb 17, 2011 at 10:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .