Question: I am using terminal with MacOSX. 

I read this [entry](http://www.tutorialspoint.com/unix/unix-using-arrays.htm) introducing about unix array. I tried to access an array as its way, but failed:

```
a=(1,2) && echo "${a[0]}"

```

this is the output:

```
1,2

```

What I expected is `1`.

What should I do?

Answer: 
`a=('1' '2') && echo "${a[0]}"` would be better like this. 

In your version you only created a one element array which contains the value "1,2".
Three things to remember while accessing an element in an index array:

1. Normal expression - hardcoded index
======================================

```
arr=(one two three)
element_0="${arr[0]}"

```

2. Normal expression - index stored in a variable
=================================================

```
arr=(it is cool to write readable code)
for ((i=0; i < ${#arr[@]}; i++)); do
    current_element=${arr[i]} # note, no '$' necessary before i
done

```

3. Arithmetic expression involving array elements
=================================================

```
arr=(100 150 350)
((sum_of_first_two = arr[0] + arr[1])) # no need for '{ }'

```