LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to put progress bar while coping (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-put-progress-bar-while-coping-767824/)

pinga123 11-09-2009 12:31 AM

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.

indiajoe 11-09-2009 01:07 AM

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

evo2 11-09-2009 01:11 AM

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

Cheers,

Evo2.


All times are GMT -5. The time now is 02:22 AM.