Home > AI > Uncategorized

Mac shell数组

1.创建数组

a=(1 2 3) # 用空格分割

a=”1 2 3″

2. 显示数组长度

${#a[@]}

3. 显示第i个元素

$a[i]

4.遍历数组

for i in ${a[@]}

do

echo “—“$i

done

Related posts:

Leave a Reply