Bash Arrays
BASH Arrays
See here.
Indexed arrays
1names[0]=Yoesf
2names[1]=David
3echo $names # will show: Yosef
4echo ${names[1]} # will show: David
bash
Assigning complete arrays. This is done by surounding a list of word with parentheses:
or even:
Associative Arrays
You have to use declare -A name before:
1-> declare -A menheight
2-> menheight[Dave]=195
3-> menheight[Sean]=170
4-> menheight[Bob]=180
5-> echo ${menheight[Dave]}
6195
7-> echo ${menheight[Sean]}
8170
9-> echo ${menheight[Bob]}
10180
11->
bash
Accessing keys and Values
Use "!" to get values:
Loop over elements: