
07-03-2009
|
|
Shell programmer, author
|
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
|
|
Quote:
Originally Posted by vgersh99
Code:
#!/bin/bash
list='201,204,301'
IFS=,; array=(${list})
typeset -i i=0
while (( $i < ${#array[*]} ))
do
echo "${array[$i]}"
((i=i+1))
done;
|
All of the above is equivalent to:
Code:
list='201,204,301'
array=( ${list//,/ } )
printf "%s\n" "${array[@]}"
|