Implement a function that sums an array, passing the array as an actual parameter to the function
#!/bin/bash
sum()
{
for i in $@
do
((sum+=i))
done
echo $sum
}
read -p "请输入一组数字: " -a arr
sum ${arr[*]}
2 Call the function, output the current user's uid gid and use variables to receive the results
#!/bin/bash
get()
{
uid=$(id -u)
gid=$(id -g)
echo uid=$uid gid=$gid
}
ret=$(get)
echo $ret
mind Mapping