Find the answer to your Linux question:
Results 1 to 5 of 5
Hi all, I would like to know how to introduce a progress bar with cp? I am modifying one of the boot scripts where in i need to cp some ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    20

    cp progress bar needed....


    Hi all,

    I would like to know how to introduce a progress bar with cp?

    I am modifying one of the boot scripts where in i need to cp some heavy files to another dest....Since these files come upto 500mb i needed a progress bar...
    would like to know how to write one?

    I googled up for this but were of no use in a boot script (binaries were not present for many cmds)
    So i ported the required binaries and modified the scripts that i found on the net to my suiting but it works fine when run in the regular env but put it in a boot script of an OS ,it beings to crib....

    So could you pls help me in getting a cp progress bar that can be included in a boot script(which is a part of the ramdisk!!)

    Thanks

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    There have been a lot of patches around in the past to add this functionality into cp, but none of them were sane implementations (horrid performance hit).

    For example:

    Gentoo Forums :: View topic - mv - sort of progress bar?



    Now, for the solution: I'd just use scp locally or rsync which can copy files locally as well, and give some output while doing it.

  3. #3
    Linux Newbie SagaciousKJB's Avatar
    Join Date
    Aug 2007
    Location
    Yakima, WA
    Posts
    162
    Personally, the best way I've found to do this with a script alone is a bit limited.

    You can basically use the 'du' or command to list the size of entire directories recursively, or if you just want to watch the progress of one file, you can use 'ls', which will be must less of a performance hit.

    Code:
    while ls -lh *destination directory or single file*; do sleep 5s && clear; done
    This will just watch the destination directory's file size, and you can pretty much just keep an eye on it all while it grows. However, it only really works for files, if you're putting something into subdirectories, it won't count that data, and that will lead to problems.

    What works equally well, but perhaps more slowly

    Code:
    while du -ha --max-depth 1 /destination/ ; do sleep 5s && clear; done

  4. #4
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,283
    Hi.

    One solution that was posted is http://www.linuxforums.org/forum/lin...tml#post537099

    This is more general in that one can use it with any process that might take a long time. It is an indicator that something is still going on, but not a precise measure of how much work is done and how much work remains ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  5. #5
    Just Joined!
    Join Date
    Oct 2010
    Posts
    2
    just use
    Code:
    rsync -P sourcefile destfile
    and you have a perfect progress information

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •