how to read a var value into array

Hi
I need to read a value of the variable into array so each character/digit will become an array element,for example:
A=147921231432545436547568678679870
The resulting array should hold each digit as an element.
Thanks a lot for any help -A

There should be some form of seperator among the values

You can use cut command inside a loop.

cut -c <position>

Yes, that would be the 1st step.

Write it for example like

A="842 5 2 64  24 11"

You can then cycle through it with for example

for ELE in ${A}; do
   echo "I want ${ELE] cookies!"
done

Next time please use code tags.
Here is the bash solution:

$ A=147921231432545436547568678679870
$ set -- $(for i in $(seq 0 $((${#A} - 1)));do printf "%s " ${A:$i:1};done)
$ echo $*
1 4 7 9 2 1 2 3 1 4 3 2 5 4 5 4 3 6 5 4 7 5 6 8 6 7 8 6 7 9 8 7 0

... or awk solution:

set -- $(awk -v v="$A" 'BEGIN{split(v,a,"");for (i=1;i<= length(v);i++) printf "%s ",a}')

I like this a little better than danmero's example, as it actually puts it in an array:

for i in $(seq 0 $((${#string}-1))); do array[$i]=${string:$i:1}; done

Which produces:

$ A=147921231432545436547568678679870; for i in $(seq 0 $((${#A}-1))); do array[$i]=${A:$i:1}; done

$ set | grep array
array=([0]="1" [1]="4" [2]="7" [3]="9" [4]="2" [5]="1" [6]="2" [7]="3" [8]="1" [9]="4" [10]="3" [11]="2" [12]="5" [13]="4" [14]="5" [15]="4" [16]="3" [17]="6" [18]="5" [19]="4" [20]="7" [21]="5" [22]="6" [23]="8" [24]="6" [25]="7" [26]="8" [27]="6" [28]="7" [29]="9" [30]="8" [31]="7" [32]="0" [33]="")

Note that this will fail for especially-large strings; just break out of the for and use a while (or a C-style for()) instead.

If that's what you're looking for, you can also create the same effect as danmero's script with sed:

$ echo 147921231432545436547568678679870 | sed 's/\(.\)/\1 /g'
1 4 7 9 2 1 2 3 1 4 3 2 5 4 5 4 3 6 5 4 7 5 6 8 6 7 8 6 7 9 8 7 0

With Z-Shell:

zsh-4.3.4% A=147921231432545436547568678679870
zsh-4.3.4% print $A[4]
9
zsh-4.3.4% print $A[-3]
8

With bash/ksh93, here string and fold:

$ a=($(fold -w1<<<$A))
$ printf "%s\n" "${a[0]}"
1
$ printf "%s\n" "${a[3]}"
9

For older shells:

$ A=147921231432545436547568678679870
$ set -- `printf "%s\n" "$A"|fold -w1`
$ printf "%s\n" "$1"
1
$ printf "%s\n" "$4"
9
$a="147921231432545436547568678679870";
@arr=split("",$a);
foreach(@arr){
print $_,"\n";
}