@nrailgun
        
        2016-06-22T06:52:46.000000Z
        字数 562
        阅读 1537
    程序设计
Array: An array is a numbered list of strings: it maps integers to strings.
With =() syntax.
names=("John" "$USER")
Glob can also be used.
files=(~/*'.jpg')
Do not use
l=$(ls)l=($(ls))
Use
l=(*)
echo ${#array[@]}
We can use a for loop to iterate over the elements
for i in "${l[@]}"; doecho "$i"done
We use the quoted form again here: "${l[@]}". Bash replaces this syntax with each element in the array properly quoted.
Use "${!l[@]}" to loop over the indices of arrays.
for i in "${!l[@]}"; doecho "${l[i]}"done
Since it works with sparse array, it better than ${#l[@]}.
