Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

When moving large directories using mv, is there a way to view the progress (%)? The cp command on gentoo had a -g switch that showed the progress.

share|improve this question
Measure pipe throughput in the shell might help, although I don't know if it's possible to easily use those tools when moving a file – Michael Mrozek Oct 1 '10 at 6:42

8 Answers 8

up vote 29 down vote accepted

You can build a patched cp and mv which then both support the -g switch to show progress. There are instructions and patches at this page. However: The page instructs you to do

$ sudo cp src/cp /usr/bin/cp
$ sudo cp src/mv /usr/bin/mv

which overwrites the original cp and mv. This has two disadvantages: Firstly, if an updated coreutils package arrives at your system, they are overwritten. Secondly, if the patched version has a problem, they might break scripts relying on standard cp and mv. I would rather do something like this:

$ sudo cp src/cp /usr/local/bin/cpg
$ sudo cp src/mv /usr/local/bin/mvg

which copies the files to /usr/local/bin which is intended for user compiled programs and gives them a different name. So when you want a progress bar, you say mvg -g bigfile /mnt/backup and use mv normally.

Also you can do alias mvg="/usr/local/mvg -g" then you only need to say mvg bigfile /mnt/backup and directly get the progress bar.

share|improve this answer
The link is dead! – tprk77 Dec 19 '14 at 16:33
Indeed. I can't find an other site carrying the files :-( – fschmitt Dec 22 '14 at 9:04

I don't like the idea to overwrite binaries from coreutil when there are simpler solutions, so here are mine:

rsync: Rsync copies files and has a -P switch for a progress bar. So if you have rsync installed, you could use a simple alias in your shells dotfile:

alias cp='rsync -aP'

The downside is, that rsync is a little bit slower than cp, but you should measure this with time and decide for your self, I can live with it :-)

Shell Script: A shell script can also create the progress bar. I found this a while ago on the net and I don't remember the source:

   strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
      | awk '{
        count += $NF
            if (count % 10 == 0) {
               percent = count / total_size * 100
               printf "%3d%% [", percent
               for (i=0;i<=percent;i++)
                  printf "="
               printf ">"
               for (i=percent;i<100;i++)
                  printf " "
               printf "]\r"
         END { print "" }' total_size=$(stat -c '%s' "${1}") count=0

This will look like:

% cp_p /home/echox/foo.dat /home/echox/bar.dat
66% [===============================>                      ]


‘bar’ - ‘cat’ with ASCII progress bar

bar is a small shell script to display a process bar for all kind of operations (cp, tar, etc.). You can find examples on the project homepage.

Its also written for the bourne shell, so it will run nearby everywhere.

share|improve this answer
I love the "unix"-ness of having a program just to create a progress bar. – Steven D Oct 1 '10 at 15:28
bar doesn't wrap mv yet. – Tobu Jan 2 '11 at 23:04
Credit for the shell script – Lamnk Jun 26 '11 at 16:42
the shell script works perfectly! – David Dai May 25 at 6:42

You can use pipe viewer command pv to show progress bar:

pv /original/file > /new/file

I often use this to copy a big file over a mounted network filesystem (combine with gzip and tar). The drawback is that you can only copy one file and not directory. And you must give the new file a name, you can not just give destination directory like cp does. However copying is not pv's purpose. It is a powerful tool and do much more than just copy file. See the homepage for more examples of pv.

A much better option is to use rsync -aP. If you want to mv instead, append the flag --remove-source-files. Add this to your .bashrc if you want to use the commands frequently:

alias rscp='rsync -aP'
alias rsmv='rsync -aP --remove-source-files'

The downside here is rsync only shows progress, not a progress bar.

share|improve this answer

There's a new tool called progress that can find any descriptor related to a running command and show progress and speed: available here

progress -w

outputs the stats for all running cp,mv etc. operations

share|improve this answer
WOW, I did not expect this to be so awesome! I simply typed progress after installing and it presented me with progress for the mv command I was currently waiting for. Thanks! – jRadd Sep 30 at 0:59

If your goal is to move/copy a directory with progress bar, but avoiding non-terminal GUI, mc (Midnight Commander) is a good choice.

share|improve this answer

To avoid coreutil patching to add progress bar to mv and cp, gcp (Goffi's CoPier) is a new alternative:

To use the same way as cp with options -r for recursivity and -v for verbosity.

It uses a file queue when multiple commands are invoked concurrently. It also allows to record copied file names in a log, see Source saving man page section for details.

Here is a good tutorial to get started with gcp:

share|improve this answer

First off: I never copy large files without using ionice, unless I know that I will not want to use the computer for half an hour or more.

Second: all my partitions are jouranled so intrapartition copying takes not time. If it is a long copy I do a du -sm on the files and df -m | grep copy_to_partition. Then if curious how much more time it will take I do the df again and see how much of the files was copied.

share|improve this answer

My solution is to use rsync. It can copy directories, remove the source files after a successful copy (thus "moving" them) and display progress reports, among many other features (most notably syncing partially copied directories and working over the network.)

Here is how I would move a directory with rsync, with progress report:

rsync -aP --remove-source-files $src $dst && rm -r $src

Make sure $src does not end in a backslash, otherwise you will get a different meaning than that of GNU cp.

The rm -r at the end is needed because --remove-source-files only removes the source files, after each one is successfully copied over, not the directories. The && makes sure to run it only if rsync completes successfully. If you are paranoid, you can replace it with some kind of recursive rmdir, such as find $src -d -exec rmdir {} +

The only glitch is that the -P option shows progress for each file, not for the entire copy operation. This might be useless if you are trying to move a directory with many tiny files. The latest development version of rsync has an alternate flag --info=progress2 that shows progress for the entire operation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.