LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-09-2009, 04:46 PM   #1
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Rep: Reputation: 16
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?
 
Old 03-09-2009, 10:03 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,520

Rep: Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944
Quote:
Originally Posted by DoME69 View Post
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.
 
Old 03-10-2009, 02:55 AM   #3
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Original Poster
Rep: Reputation: 16
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...
 
Old 03-10-2009, 06:20 AM   #4
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Original Poster
Rep: Reputation: 16
anyone?
 
Old 03-10-2009, 06:36 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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.
 
Old 03-10-2009, 07:17 AM   #6
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Original Poster
Rep: Reputation: 16
...

......

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
 
Old 03-10-2009, 01:41 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mv with progress bar gbowden Linux - General 28 08-14-2013 04:42 AM
How to display file copy progress bar bmcneely0 Linux - General 12 02-19-2012 03:19 PM
cp progress bar edwardsiow Linux - General 26 09-04-2011 08:53 AM
cp with progress bar? Rotwang Linux - General 5 04-27-2005 07:49 PM
How the Progress Bar of a copy file/directory process is progressed?(any logic)? kiranprashant Programming 3 03-08-2005 06:16 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration