How can I make a progress bar while copying a directory with cp?
I suppose I could compare the number of files in the source directory to the number of files in the target directory as cp progresses, or perhaps do it with folder size instead? I tried to find examples, but all bash progress bars seem to be written for copying single files. I want to copy a bunch of files (or a directory, if the former is not possible).
Solution 1:
You can also use rsync
instead of cp
like this:
rsync -Pa source destination
Which will give you a progress bar and estimated time of completion. Very handy.
Solution 2:
To show a progress bar while doing a recursive copy of files & folders & subfolders (including links and file attributes), you can use gcp
(easily installed in Ubuntu and Debian by running "sudo apt-get install gcp"):
gcp -rf SRC DEST
Here is the typical output while copying a large folder of files:
Copying 1.33 GiB 73% |##################### | 230.19 M/s ETA: 00:00:07
Notice that it shows just one progress bar for the whole operation, whereas if you want a single progress bar per file, you can use rsync
:
rsync -ah --progress SRC DEST
Solution 3:
You may have a look at the tool vcp
. Thats a simple copy tool with two progress bars: One for the current file, and one for overall.
EDIT
Here is the link to the sources: http://members.iinet.net.au/~lynx/vcp/ Manpage can be found here: http://linux.die.net/man/1/vcp
Most distributions have a package for it.