The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 04-23-2009
lavascript lavascript is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 47
ok apologies set -A is for ksh.

Are you doing a while loop for another task or is it purely for this function?

Assuming you want to do other things in your while loop you can try the below code. Otherwise you don't need the while. Saying that you could use while instead of for but below would need changes.

Code:


array=""
array_count=0

for element in $input
do
     ... do some checking....
     array[$array_count]=$element
     ... do other stuff .....
     array_count=$(( $array_count + 1 ))
done