For Loop

I have executed the command

numOfAcct=`ls availablityFax.acc* | wc -l`
echo "${numOfAcct}

numOfAcct displays 4

I want to use a for loop to execute a call to another program numOfAcct times. How do you write the for portion?

I originally had:
for i in $numOfAcct}
do
echo "ME"
done

This did not execute 4 times.

This didn't work because the for loop works off a list.
(For each file in a directory do this...for each word in a line, do this)

You should check the man page and try using a while loop or change the condition for the FOR loop to look at the files instead of the number of files. I don't know which you need without further info.

numOfAcct=`ls availablityFax.acc*`
echo "${numOfAcct}

numOfAcct displays each filename

for i in $numOfAcct}
do
echo "$i"
done

This would list all the files one by one inside the for loop.

I would use until

#!/bin/ksh
numOfAcct=4
ncounter=1
until [[ $ncounter -gt 4 ]];do
echo $ncounter
ncounter=`calc "$ncounter + 1"`
done

That will get pretty slow if you start working with large numbers...

If you're going to use ksh, why bother calling calc?

until [[ $something -eq 10 ]]; do
print $something
something=$((something+1))
done

OP, it really matter what you're trying to accomplish...
Does each filename need to be sent to another command as an argument?
If so, hoghunter is pointing you right...

for each in availabilityFax* ; do
command $each
done

will this help?

======================
let count=0

for x in `ls availablityFax.acc*`
do
let count=$count+1
done

echo $count

thanks :slight_smile: