End of loop condition required???

Hi

i have a variable with lots of tokens seperated with spaces.

e.g VAR="ABC DEF GHSD GHQS TUTSD JHDTQ QDHQ CDQKDGQ WQUTQD DQUTQD DQJGDQ QDTQD WDQUTQDU QDUGQD QDJGQD DQUTDUQ QDUIDTQ"
i want to separate all of the above tokens and call a script with each of the token e.g sh script.sh <TOKEN>

Can anybody provide the logic script ? I am cofused about the end of the loop condition.

Thanks

Can you show us what you have ? Perhaps, we can guide you better when we see the script.

#!/user/bin
NAMES=`ls *.txt`
echo $NAMES

The content of this NAMES variable are TOKENS seperated by spaces.

i want to pass each token to another script called run.sh as follows:

while [<ALL tokens in $NAMES one by one>]
do
sh run.sh <TOKEN>
done

please provide the logic for seperating NAMES token and then calling run.sg with each token ????

You would be better off with using a for loop

NAMES=`ls *.txt`
echo $NAMES
for file in $NAMES
do
  sh run.sh $file
done

or better yet

for file in *.txt
do
  sh run.sh $file
done

Thanks.

Its working !!!