#!/bin/bash
function fun()
{
sum=0
i=0
b=($*)
while [ $i -lt ${#b[*]} ]
do
((sum += ${b[i]}))
((i++))
done
echo $sum
}
read -p "请输入数组" -a a
fun ${a[*]}
function fun2()
{
a=`id -u`
b=`id -g`
echo $a $b
}
p=(`fun2`)
uid=${p[0]}
pid=${p[1]}
echo $uid $pid
XMind