Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I echo progress dots?

Status
Not open for further replies.

kgeter

Programmer
Oct 25, 2002
1
US
How do I echo dots to show the user that a script is executing and progressing? Example: in a shell script I copy a bunch of files from one directory to another. This takes awhile, so it would be nice to echo dots to show the user something is happening.

Copying files . . . . . . . . . . . . .
Done!

Where the dots line would grow as the copying progresses. I've searched Google, but can't find anything on this. I'm thinking it involves a while loop. I'd prefer to do this in sh, ksh, or bash.
 
Sure, you can make a list file, then get a Final Count and start your count at 0.

#!/usr/bin/ksh -p

COUNT=0
FCOUNT=`/usr/bin/cat list|/usr/bin/wc -l`

print "Now starting file copy\c"
while [ ${COUNT} -ne ${FCOUNT} ]
do
/usr/bin/cp -p ${SOMEFILE} ${SOMEWHERE}
print ".\c"
let COUNT=COUNT+1
done

I think there is an easier way to do this with printf, but I have never used looked into that solution.
 


make sure to do a print at the end to close the new line or your prompt will be at the end of your dots.


----
 
#########Linux#######
while test ! -e $targetfile
do echo -n "."
sleep 1
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top