How to convert text into an array in Ubuntu Linux

Let's say we have some word:

tamir@tamir:~/projects/search$ cat mini_text

abcdef

In order to convert it to array we can use 'sed' command:
tamir@tamir:~/projects/search$ array=($(cat mini_text | sed 's/\(.\)/\1 /g'))

And to get all elements of array:
tamir@tamir:~/projects/search$ echo ${array[@]}
a b c d e f

Get specific element of array:
tamir@tamir:~/projects/search$ echo ${array[3]} 
d

Comments