LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-09-2009, 12:31 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 36
How to put progress bar while coping


Hi guys I want to create a script which will show the amount of data that is been copied from one location to another location.

For example:
Say i have a file called abc.img which is approximately 4 gb of size therfore everytime i copy the file from one location to another i want a progress bar to appear like 50% completed 51% completed and so on.

I have no idea how to establish that.
Please give some suggestion on this.
 
Old 11-09-2009, 01:07 AM   #2
indiajoe
Member
 
Registered: Jan 2009
Location: India
Distribution: Porteus atma
Posts: 84

Rep: Reputation: 21
Script

Hi,
I once wanted exactly the same thing.
The shell script I made worked as follows.
Use the two arguments given while coping to understand what is copied to where.
cp source destination &
Use du command to find the file size of the source. Multiply that value with 10/100 (Or what ever step size you want). Construct an while condition (till size of destination is less than source) to do the following.
Check the size of the destination using du command,
if it is more than i*(SourceSize*10/100) { where i iterates from 0 to 10}
print "i*10% completed", and increment i
sleep for some time.
Close while loop.

Thats all. I hope I am clear.
I shall try to find out the script I used, It is somewhere lost in backups. But the real fun is actually writing the shell script yourself. Define an alias also for this script (say alias ccp="your_cool_copy.sh")
-Cheers
indiajoe
 
Old 11-09-2009, 01:11 AM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Depends what program you are using to copy the file(s). rsync has the --progress flag.

Cheers,

Evo2.
 
  


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
cp progress bar edwardsiow Linux - General 26 09-04-2011 08:53 AM
how to put progress bar or image on booting time ? kkpal Programming 1 03-06-2008 01:42 PM
cp: progress bar chii-chan Linux - General 2 10-30-2003 06:30 PM
Progress Bar zael Programming 3 10-01-2003 12:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:46 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration