Bash 2.x提供了创建一维数组的能力。
$declare -a nums=(45 33 100 65)
$echo ${nums[0]}
45
$echo ${nums[*]}
45 33 100 65
$states=(ME [3]=CA [2]=CT)
$echo ${states[*]}
ME CA CT
$names=(Tom Peter Mike)
$names[5]=panda
$echo "All the array elements are ${names[*]}"
All the array elements are Tom Peter Mike panda
$echo "The number of elements in the array is ${#names[*]}"
The number of elements in the array is 4
$unset names
=-=-=-=-=
Powered by Blogilo
原文:http://www.cnblogs.com/pandachen/p/4824595.html