Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any good tool in GNU/Linux that copy files like cp, but also shows progress and limits speed (and changes limit without interruption) like pv?


find source_directory | cpio -H newc -o | pv -s `du -bs source_directory/ | awk '{print $1}'` | (cd /destination/directory && cpio -di)

Also rsync -aP source_directory /destionation/directory/, but this shows progress bars individually and can't change rate after started.

Or may be I should just write a wrapper for pv/cpio? Done.

share|improve this question
+1 Wow, I'm interested in this too! – dag729 Jun 22 '10 at 18:37
up vote 9 down vote accepted

Written the script to use find, cpio and pv to accomplish the task. The rate can be limited.

Mirroring it here:


set -e

if [ $# -lt 2 ]; then
    echo "cppv - copy files with progress bar and rate limiting ability"
    echo "Usage: cppv source_file[s] destination_file_or_directory"
    echo "No other non-positional command line arguments can be given"
    echo "Always recurses like find"
    echo "You can change copying speed limit on the fly with \"pv -R\" if you find out pv's PID"
    echo "Use FIND_OPTS, PV_OPTS, CPIO_O_OPTS, CPIO_I_OPTS to override arguments to the pipeline parts"
    echo "Examples:"
    echo "    cppv a b # Copy file a to b. Just calls \"pv a > b\""
    echo "    cppv a d/ # Copy file a to d/a. Calls \"find a | cpio -o | pv | (cd d && cpio -i)\""
    echo "    cppv *{01..26}*.mkv /mnt/usb/ # Copy all matching files to /mnt/usb/."
    echo "    cppv dir1 dir2 # duplicate dir1"
    echo "    PV_OPTS=\"-L 1M\" cppv . /tmp/ # Limit copying rate to 1M"
    echo "    cppv /home/vi/bin /tmp/ # Warning: Copy /home/vi/bin to /tmp/home/vi/bin"
    exit 1

true ${CPIO_O_OPTS:="-H newc -0o"}
true ${CPIO_I_OPTS:="-0diu --no-absolute-filenames"}
true ${FIND_OPTS:="-depth -print0"}

ARGS=( "$@" );

unset ARGS[$#-1];

if [[ ( "${1:0:1}" == "-"  && ! -e "$1" ) || ( "${DEST:0:1}" == "-" && ! -e "$DEST" )  ]]; then
    echo "There should not be any command line options. Only file names." >&2
    exit 1;


if [[ $# > 2 || "${DEST:${#DEST}-1:1}" == "/" || -d $DEST ]]; then
elif [[ -d "$1" && ! -d "$2" ]]; then
    mkdir "$DEST";
    DEST=`readlink -f "$DEST"`;
    cd "$1";

if [ $DIRMODE == 0 ]; then
    pv "$1" > "$2" && exit 0;

if [ ! -d "$DEST" ]; then
    echo Not a directory: "$DEST" >&2
    exit 1

if [ "${1:0:1}" == "/" ]; then
    echo "Warning: it will do a bit different thing than usual cp" >&2
    echo "    For example, copying $1 to $DEST$1, not to $DEST/`basename $1`" >&2

SIZE=`du -sb "${ARGS[@]}" | perl -ne '/^(\d+)/ and $q+=$1; END{print $q}'`

find "${ARGS[@]}" $FIND_OPTS | cpio $CPIO_O_OPTS | pv -s $SIZE $PV_OPTS | (cd "$DEST" && cpio $CPIO_I_OPTS)

Someone, please test it.

share|improve this answer
+1 for you! I'm afraid I can't get around to testing it but it look pretty promising! Nice work! – BloodPhilia Jun 22 '10 at 20:39
What is pv? Is that Pipe Viewer? (It's not installed on Ubuntu 10.04 by default, so I don't have it). – Stefan Lasiewski Jun 22 '10 at 21:47
@Stefan Lasiewski Yes, it is. apt-get install pv – Vi. Jun 22 '10 at 22:03
Note for users: the script fails on large (>2GB) files. – Vi. Feb 26 '12 at 1:44

I suggest you check this out:

It looks rather neat! =)

share|improve this answer
It looks REALLY neat! Thanks! – dag729 Jun 22 '10 at 18:39
@dag729 You're welcome! ;) – BloodPhilia Jun 22 '10 at 18:44
"tt will increase every-time a file is copied to $DEST" - bad, I want it to work both for many small files and one big. And no rate limiting. – Vi. Jun 22 '10 at 18:56
@Vi - perhaps you could adapt it a little? It's only an example on how to display a progress bar. – BloodPhilia Jun 22 '10 at 18:58
No, I've written the wrapper around "cpio | pv | cpio". Soon will publish it here. – Vi. Jun 22 '10 at 20:01

Try gcp. Should be available on Ubuntu.

share|improve this answer
Works (although handling of special files is lacking) – Vi. Feb 26 '12 at 1:42
Installed fine on Ubuntu Oneric but gave me errors and crashed on a simple gcp file destination – capdragon Apr 27 '12 at 15:48

You must log in to answer this question.

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