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).
相关问题
- JQ: Select when attribute value exists in a bash a
- bash print whole line after splitting line with if
- “command not found” errors in expect script execut
- grep using grep results
- UNIX Bash - Removing double quotes from specific s
相关文章
- Check if directory exists on remote machine with s
- Reverse four length of letters with sed in unix
- Launch interactive SSH bash session from PHP
- BASH: Basic if then and variable assignment
- Bash script that creates a directory structure
- Test if File/Dir exists over SSH/Sudo in Python/Ba
- How can I create a “tmp” directory with Elastic Be
- Spread 'sed' command over multiple lines
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.
There's a tool
pv
to do this exact thing: http://www.ivarch.com/programs/pv.shtmlThere's a ubuntu version in apt
A simple unix way is to go to the destination directory and do
watch -n 5 du -s
. Perhaps make it more pretty by showing as a bar . This can help in environments where you have just the standard unix utils and no scope of installing additional files . du-sh is the key , watch is to just do every 5 seconds. Pros : Works on any unix system Cons : No Progress BarHow about something like
It finds all the files in the current directory, pipes that through PV while giving PV an estimated size so the progress meter works and then piping that to a CP command with the --parents flag so the DEST path matches the SRC path.
One problem I have yet to overcome is that if you issue this command
the destination path becomes /www/test/home/user/test/....FILES... and I am unsure how to tell the command to get rid of the '/home/user/test' part. That why I have to run it from inside the SRC directory.
Here another solution: Use the tool
bar
You could invoke it like this:
You have to go the way over tar, and it will be inaccurate on small files. Also you must take care that the target directory exists. But it is a way.
You can also use
rsync
instead ofcp
like this:rsync -Pa source destination
Which will give you a progress bar and estimated time of completion. Very handy.