#!/bin/bash arr=(12 36 '你好') length=${#arr} echo "長度為:$length" # for 遍歷 for item in ${arr[*]} do echo $item done i=0 # until遍歷 echo until begin until (( i++ > $length )) do echo ${arr[(( i-1 ))]} done echo end # for遍歷 echo for begin for (( k=0; k <= $length; k++ )) do echo ${arr[$k]} done i=0 echo while begin #while遍歷 while (( i++ <= $length )) do echo ${arr[(( i-1 )) ]} done