-A
宣告陣列。以下設定 grades 是字典陣列。
[dywang@dywmac ~]$ declare -A grades
[dywang@dywmac ~]$ grades=(["dywang"]='60' ["linda"]='80' ["peter"]='92' ["rita"]='87')
[dywang@dywmac ~]$ echo "${grades['linda']}" 80
[dywang@dywmac ~]$ echo "${grades[@]}" 87 92 80 60
[dywang@dywmac ~]$ echo "${!grades[@]}" rita peter linda dywang
[dywang@dywmac ~]$ echo "${#grades[@]}" 4
[dywang@dywmac ~]$ grades['linda']=85 [dywang@dywmac ~]$ echo "${grades['linda']}" 85