m_array=(1 2 3 4)
m_array[0]=0 m_array[1]=1 m_array[2]=2
echo "数组元素个数为: ${#m_array[*]}" echo "数组元素个数为: ${#m_array[@]}"
echo ${m_array[0]} echo ${m_array[1]}
sum=0; for value in ${m_array[*]}; do sum=`expr $sum + $value`; echo $sum; done
sum=0; len=${#m_array[*]} for (( index = 0; index < ${len}; index++ )); do sum=`expr ${sum} + ${m_array[index]}`; echo $sum; done
[user@manjaro ~]$ ./test.sh a b c $1 $2 $3,依次为第一个参数,第二个参数,第三个参数 $@ 参数列表
echo "长度: $#"
echo "参数 1: $1" echo "参数 2: $2" echo "参数 3: $3"
echo "参数列表:$@"
echo "所有参数按照字符串显示: $*"
2021-07-17