Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
#!/bin/bash
files=`ls -l | wc -l`
copied=1
clear
echo " Please wait, copy in progress"
while [ $files -ge $copied ] ;do
pct=$((100 * copied / $files))
copied=$((copied + 1))
echo -en ".$pct%\b\b\b" ## you can use # or anything instead of dots
sleep 1
done
echo -e "\n"
echo " The operation is complete"
echo -e "\n"
but i don't know how to modify this code so that i can use it to copy large files from a CD to the hard disk and at the same time showing the progress bar.
i am sorry to tell that i am newbie and not so understand the above sample codes..
maybe you will ask me to go back study hard..but i really need to solve this problem urgent and dont have time for me to study. believe or not depend on you...
This part is the name of my script ------> ./test
To use ./test , I made it execute with the command: chmod +x test
or you could use the method of : sh test
original_file ---------> Is actually a directory in your case.
that is /mnt/cdrom
destination_file --------> Is actually a directory in your case.
~/Desktop/CDcontents/
So, it might look like this...
./test /mnt/cdrom ~/Desktop/CDcontents/
Because it's a directory, you may need to play with the copy statement. Look into man cp for that. Maybe something like.....
cp -R $1 $2 &
This part is the name of my script ------> ./test
To use ./test , I made it execute with the command: chmod +x test
or you could use the method of : sh test
original_file ---------> Is actually a directory in your case.
that is /mnt/cdrom
destination_file --------> Is actually a directory in your case.
~/Desktop/CDcontents/
So, it might look like this...
./test /mnt/cdrom ~/Desktop/CDcontents/
Because it's a directory, you may need to play with the copy statement. Look into man cp for that. Maybe something like.....
cp -R $1 $2 &
wow~~thanks a lot!!! let's me try first...i am appreciate your help...
This works well for file->file, but file->directory will result in an endless loop you have to ctrl-c out of:
Code:
[mk6032@linuxquestions]# cp movie.avi /srv/nfs/media/video/
Preparing to copy
/root/cp_progress.sh: line 16: /srv/nfs/media/video/: Is a directory
########################################################### 0%
[mk6032@linuxquestions]#
It needs to run a check on the destination first:
if [ -d $2 ] then ....
-r for recursive (if you want to copy entire directories)
src for the source file (or wildcards)
dst for the destination
--progress to show a progress bar
Honestly, rsync is only a little slower than cp for local copies and is so much better featured.
You can also look at pv (Pipe Viewer), but honestly, for the specific solution you're looking for--copying a tree of files off a CD-ROM with a progress bar--rsync is the best solution, as nonzenze said.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.