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 -->
  #3 (permalink)  
Old 07-02-2009
mglenney mglenney is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 85
Quote:
Originally Posted by vgersh99 View Post
Code:
#!/bin/ksh

list='201,204,301'

IFS=,; set -A array ${list}

typeset -i i=0
while (( $i < ${#array[*]} ))
do
  echo "${array[$i]}"
  ((i=i+1))
done;
I'm using Bash which doesn't have -A option for set and, from what I can tell, doesn't have an equivalent. I wish it did because you basically do what I need in a single line with your example.

For now I've solved my problem this way:

Code:
while [ "$1" != "" ]; do
  case $1 in
    -p  )               shift
                        case $1 in
                          *,* ) pools=( $(for i in $(eval echo {$1}); do echo $i; done | sort) ) ;;
                          *   ) pools=$1 ;;
                        esac
                        ;;