LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   copy at terminal with progress bar. (https://www.linuxquestions.org/questions/programming-9/copy-at-terminal-with-progress-bar-710339/)

DoME69 03-09-2009 04:46 PM

copy at terminal with progress bar.
 
Hi...

after searching i cant find script that can deal with directories
all the found scripts work file to file and not directory to directory

someone know script that can deal with all this situation?

TB0ne 03-09-2009 10:03 PM

Quote:

Originally Posted by DoME69 (Post 3470147)
Hi...

after searching i cant find script that can deal with directories
all the found scripts work file to file and not directory to directory

someone know script that can deal with all this situation?

Going to have to be a little more clear on what you're looking to do, before you can get help. Describe your problem/goal.

Are you trying to copy whole directories from one location to another? Try "cp -R <source> <destination>". Look at the man page for CP, to see all the options.

DoME69 03-10-2009 02:55 AM

Hi ...

i know that cp -r [source] [destination] is to copy libraries.

what i want that after that progress bar appear and show % complete, estimate time...

DoME69 03-10-2009 06:20 AM

anyone?

pixellany 03-10-2009 06:36 AM

It would help to show an example of the scripts you have found...

If they are doing a progress bar in the terminal, I assume they are using something like dialog for the display.

DoME69 03-10-2009 07:17 AM

...
 
......

Quote:

#!/bin/sh
#
# cpbar -- era 2008-05-21 for unix.com
#
# Depends:
# stat
# cp
# awk

syntax () {
echo "Syntax: $0 srcfile destfile" >&2
echo " " "$@" >&2
exit 1
}

test -r "$1" || syntax "File '$1' not found"
test -d "$2" && syntax "Must name destination file ('$2' is a directory)"

size=`stat -c %s "$1"`

cp "$1" "$2" &
cppid=$!

trap 'echo; kill $cppid; rm -f "$2"; exit 127' 1 2 3 5 15

while true; do
nsize=`stat -c %s "$2"`
awk -v f1="$1" -v f2="$2" -v size=$size -v nsize=$nsize '
BEGIN { printf "Copying %s to %s: %4.2f%%\r", f1, f2, 100*nsize/size }'
case $nsize in $size) break ;; esac
sleep 1
done

echo

wait $cppid

pixellany 03-10-2009 01:41 PM

What is the code that actually makes the progress bar?

But--as for the original question--instead of using "stat" to get the file size, I'm guessing you'll want something like du (unless there's a stat option that does the same thing)


All times are GMT -5. The time now is 12:02 PM.