|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simple Q -- count variable in loop
I need to do something very simple, and as I'm a newbie, I need some help. How do I get a count of items processed in a loop? Using ksh.
A simple example: for file in `ls ${stagedir}/*.txt` do mv ${file} ${workdir} # count variable here -- x++ done echo "${x} files were moved" Thanks! Stacy |
|
#2
|
|||
|
|||
|
Never mind. Got it. Sorry for the super-simple question!
count=0 for file in `ls ${stagedir}/*.txt` do mv ${file} ${workdir} count=`expr $count + 1` done echo "$count files were moved" Thanks, Stacy |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Simple Q -- count variable in loop |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|