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$ 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
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
tamir@tamir:~/projects/search$ echo ${array[3]}
d
Comments
Post a Comment